[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[UNIKRAFT/LWIP PATCH v3 1/2] 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 e794c37..66c0ac9 100644
--- a/uknetdev.c
+++ b/uknetdev.c
@@ -83,8 +83,12 @@ struct lwip_netdev_data {
 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)
@@ -686,16 +690,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




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.