Cater to devices which: (a) may want to sleep in the callbacks; (b) only have IPv4 support; (c) need all the programming to happen while the netdev is up. Drivers attach UDP tunnel offload info struct to their netdevs, where they declare how many UDP ports of various tunnel types they support. Core takes care of tracking which ports to offload. Use a fixed-size array since this matches what almost all drivers do, and avoids a complexity and uncertainty around memory allocations in an atomic context. Make sure that tunnel drivers don't try to replay the ports when new NIC netdev is registered. Automatic replays would mess up reference counting, and will be removed completely once all drivers are converted. v4: - use a #define NULL to avoid build issues with CONFIG_INET=n.
Showing the changes to include/linux (1 of 8 files). Show all
Unified · Split
| @@ -65,6 +65,8 @@ struct wpan_dev; · 64 unmodified lines | |||
| 65 | struct mpls_dev; | 65 | struct mpls_dev; |
| 66 | /* UDP Tunnel offloads */ | 66 | /* UDP Tunnel offloads */ |
| 67 | struct udp_tunnel_info; | 67 | struct udp_tunnel_info; |
| 68 | struct udp_tunnel_nic_info; | ||
| 69 | struct udp_tunnel_nic; | ||
| 68 | struct bpf_prog; | 70 | struct bpf_prog; |
| 69 | struct xdp_buff; | 71 | struct xdp_buff; |
| 70 | 72 | ||
| @@ -1836,6 +1838,10 @@ enum netdev_priv_flags { · 1765 unmodified lines | |||
| 1836 | * | 1838 | * |
| 1837 | * @macsec_ops: MACsec offloading ops | 1839 | * @macsec_ops: MACsec offloading ops |
| 1838 | * | 1840 | * |
| 1841 | * @udp_tunnel_nic_info: static structure describing the UDP tunnel | ||
| 1842 | * offload capabilities of the device | ||
| 1843 | * @udp_tunnel_nic: UDP tunnel offload state | ||
| 1844 | * | ||
| 1839 | * FIXME: cleanup struct net_device such that network protocol info | 1845 | * FIXME: cleanup struct net_device such that network protocol info |
| 1840 | * moves out. | 1846 | * moves out. |
| 1841 | */ | 1847 | */ |
| @@ -2134,6 +2140,8 @@ struct net_device { · 292 unmodified lines | |||
| 2134 | /* MACsec management functions */ | 2140 | /* MACsec management functions */ |
| 2135 | const struct macsec_ops *macsec_ops; | 2141 | const struct macsec_ops *macsec_ops; |
| 2136 | #endif | 2142 | #endif |
| 2143 | const struct udp_tunnel_nic_info *udp_tunnel_nic_info; | ||
| 2144 | struct udp_tunnel_nic *udp_tunnel_nic; | ||
| 2137 | }; | 2145 | }; |
| 2138 | #define to_net_dev(d) container_of(d, struct net_device, dev) | 2146 | #define to_net_dev(d) container_of(d, struct net_device, dev) |
| 2139 | 2147 | ||