From ed8c12191637c125a5c4acc9f14777b8fe6588a9 Mon Sep 17 00:00:00 2001 From: Luke Craig Date: Wed, 1 Apr 2026 09:40:53 -0400 Subject: [PATCH 1/3] fix igloonet --- src/netdevs/igloonet.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/netdevs/igloonet.c b/src/netdevs/igloonet.c index d20555e..31a4937 100644 --- a/src/netdevs/igloonet.c +++ b/src/netdevs/igloonet.c @@ -150,7 +150,10 @@ static void igloonet_setup(struct net_device *dev) dev->flags |= IFF_NOARP; dev->flags &= ~IFF_MULTICAST; - dev->priv_flags |= IFF_LIVE_ADDR_CHANGE | IFF_NO_QUEUE; + + /* Add IFF_NO_ADDRCONF to prevent the IPv6 DAD crash */ + dev->priv_flags |= IFF_LIVE_ADDR_CHANGE | IFF_NO_QUEUE | IFF_NO_ADDRCONF; + #if LINUX_VERSION_CODE >= KERNEL_VERSION(6,13,0) dev->lltx = true; dev->features |= NETIF_F_SG | NETIF_F_FRAGLIST; From a6181f0ad8d1083df1200c646213653488f29a0f Mon Sep 17 00:00:00 2001 From: Luke Craig Date: Wed, 1 Apr 2026 11:04:13 -0400 Subject: [PATCH 2/3] portal_net: fixup flags --- src/portal/portal_net.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/portal/portal_net.c b/src/portal/portal_net.c index 547ea73..e89098c 100644 --- a/src/portal/portal_net.c +++ b/src/portal/portal_net.c @@ -62,16 +62,19 @@ void handle_op_set_netdev_state(portal_region *mem_region) rtnl_lock(); if (requested_state) { if (!(ndev->flags & IFF_UP)) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,13,0) - ret = dev_open(ndev, NULL); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0) + ret = dev_change_flags(ndev, ndev->flags | IFF_UP, NULL); #else - ret = dev_open(ndev); + ret = dev_change_flags(ndev, ndev->flags | IFF_UP); #endif } } else { if (ndev->flags & IFF_UP) { - dev_close(ndev); // dev_close returns void - ret = 0; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0) + ret = dev_change_flags(ndev, ndev->flags & ~IFF_UP, NULL); +#else + ret = dev_change_flags(ndev, ndev->flags & ~IFF_UP); +#endif } } rtnl_unlock(); From eac75cd88d93d6ed9fb7b9255a63efb4349be501 Mon Sep 17 00:00:00 2001 From: Luke Craig Date: Wed, 1 Apr 2026 11:04:36 -0400 Subject: [PATCH 3/3] igloonet: fixup --- src/netdevs/igloonet.c | 52 ++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/src/netdevs/igloonet.c b/src/netdevs/igloonet.c index 31a4937..009a1d2 100644 --- a/src/netdevs/igloonet.c +++ b/src/netdevs/igloonet.c @@ -19,21 +19,21 @@ static void set_multicast_list(struct net_device *dev) {} #if LINUX_VERSION_CODE >= KERNEL_VERSION(6,13,0) -// 6.13+ uses dev_lstats for stats +// 6.13+ uses dev_lstats for stats (returns void) static void igloonet_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) { dev_lstats_read(dev, &stats->tx_packets, &stats->tx_bytes); } -#else -// 4.10 uses per-cpu stats +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0) +// 4.11 to 6.12 uses per-cpu dstats (returns void) struct pcpu_dstats { u64 tx_packets; u64 tx_bytes; struct u64_stats_sync syncp; }; -static struct rtnl_link_stats64 *igloonet_get_stats64(struct net_device *dev, - struct rtnl_link_stats64 *stats) +static void igloonet_get_stats64(struct net_device *dev, + struct rtnl_link_stats64 *stats) { int i; for_each_possible_cpu(i) { @@ -49,6 +49,16 @@ static struct rtnl_link_stats64 *igloonet_get_stats64(struct net_device *dev, stats->tx_bytes += tbytes; stats->tx_packets += tpackets; } +} +#else +// 4.10 and older fall back to dev->stats (returns struct rtnl_link_stats64 *) +static struct rtnl_link_stats64 *igloonet_get_stats64(struct net_device *dev, + struct rtnl_link_stats64 *stats) +{ + stats->tx_packets = dev->stats.tx_packets; + stats->tx_bytes = dev->stats.tx_bytes; + stats->rx_packets = dev->stats.rx_packets; + stats->rx_bytes = dev->stats.rx_bytes; return stats; } #endif @@ -58,12 +68,16 @@ static netdev_tx_t igloonet_xmit(struct sk_buff *skb, struct net_device *dev) #if LINUX_VERSION_CODE >= KERNEL_VERSION(6,13,0) dev_lstats_add(dev, skb->len); skb_tx_timestamp(skb); -#else +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0) struct pcpu_dstats *dstats = this_cpu_ptr(dev->dstats); u64_stats_update_begin(&dstats->syncp); dstats->tx_packets++; dstats->tx_bytes += skb->len; u64_stats_update_end(&dstats->syncp); +#else + /* 4.10 and older fallback - kernel will auto-report dev->stats */ + dev->stats.tx_packets++; + dev->stats.tx_bytes += skb->len; #endif dev_kfree_skb(skb); return NETDEV_TX_OK; @@ -75,15 +89,17 @@ static int igloonet_dev_init(struct net_device *dev) dev->pcpu_stat_type = NETDEV_PCPU_STAT_LSTATS; netdev_lockdep_set_classes(dev); return 0; -#else +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0) dev->dstats = netdev_alloc_pcpu_stats(struct pcpu_dstats); if (!dev->dstats) return -ENOMEM; return 0; +#else + return 0; #endif } -#if LINUX_VERSION_CODE < KERNEL_VERSION(6,13,0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6,13,0) && LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0) static void igloonet_dev_uninit(struct net_device *dev) { free_percpu(dev->dstats); @@ -101,7 +117,7 @@ static int igloonet_change_carrier(struct net_device *dev, bool new_carrier) static const struct net_device_ops igloonet_netdev_ops = { .ndo_init = igloonet_dev_init, -#if LINUX_VERSION_CODE < KERNEL_VERSION(6,13,0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6,13,0) && LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0) .ndo_uninit = igloonet_dev_uninit, #endif .ndo_start_xmit = igloonet_xmit, @@ -151,8 +167,10 @@ static void igloonet_setup(struct net_device *dev) dev->flags |= IFF_NOARP; dev->flags &= ~IFF_MULTICAST; - /* Add IFF_NO_ADDRCONF to prevent the IPv6 DAD crash */ - dev->priv_flags |= IFF_LIVE_ADDR_CHANGE | IFF_NO_QUEUE | IFF_NO_ADDRCONF; + dev->priv_flags |= IFF_LIVE_ADDR_CHANGE; +#ifdef IFF_NO_QUEUE + dev->priv_flags |= IFF_NO_QUEUE; +#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(6,13,0) dev->lltx = true; @@ -181,10 +199,9 @@ static void igloonet_dellink(struct net_device *dev, struct list_head *head) { pr_info("igloonet: preventing deletion of %s\n", dev->name); return; - // unregister_netdevice_queue(dev, head); } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,13,0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0) static int igloonet_validate(struct nlattr *tb[], struct nlattr *data[], struct netlink_ext_ack *extack) #else @@ -212,14 +229,9 @@ struct net_device* igloonet_init_one(const char *devname) struct net_device *dev_igloonet; struct igloonet_priv *priv; int err; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,13,0) - /* allocate without calling the setup callback so we can copy the - * requested name into dev->name before setup runs (setup may - * reference dev->name). We'll call igloonet_setup() ourselves. */ - dev_igloonet = alloc_netdev(0, devname, NET_NAME_USER, igloonet_setup); -#else + + /* allocate passing sizeof(struct igloonet_priv) to properly allocate private memory */ dev_igloonet = alloc_netdev(sizeof(struct igloonet_priv), devname, NET_NAME_USER, igloonet_setup); -#endif if (!dev_igloonet) return NULL;