|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT/LWIP PATCH v2 2/3] uknetdev: Extend private state of network interface
We introduce an encapsulating structure for keeping private information
of network interfaces which is intended for internal use.
Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
---
uknetdev.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/uknetdev.c b/uknetdev.c
index 7047352..5e4ffbe 100644
--- a/uknetdev.c
+++ b/uknetdev.c
@@ -74,8 +74,12 @@
static uint16_t rx_headroom = ETH_PAD_SIZE;
static uint16_t tx_headroom = ETH_PAD_SIZE;
+struct uk_netif_state {
+ struct uk_netdev *netdev;
+};
+
#define netif_to_uknetdev(nf) \
- ((struct uk_netdev *) (nf)->state)
+ (((struct uk_netif_state *) (nf)->state)->netdev)
static uint16_t netif_alloc_rxpkts(void *argp, struct uk_netbuf *nb[],
uint16_t count)
@@ -618,16 +622,20 @@ struct netif *uknetdev_addif(struct uk_netdev *n
static const void *pethernet_input = NETIF_INPUT;
struct netif *nf;
struct netif *ret;
+ struct uk_netif_state *state;
- nf = mem_calloc(1, sizeof(*nf));
+ nf = mem_calloc(1, sizeof(*nf) + sizeof(*state));
if (!nf)
return NULL;
+ state = (struct uk_netif_state *) (nf + 1);
+ state->netdev = n;
+
ret = netif_add(nf,
#if LWIP_IPV4
ipaddr, netmask, gw,
#endif /* LWIP_IPV4 */
- n, uknetdev_init, UK_READ_ONCE(pethernet_input));
+ state, uknetdev_init, UK_READ_ONCE(pethernet_input));
UK_ASSERT(nf->input);
if (!ret) {
--
2.20.1
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |