From 5c907ac28f19fdef880d56e0ffc15a0d6369c372 Mon Sep 17 00:00:00 2001 From: Murat Sezgin Date: Thu, 18 May 2023 08:47:34 -0700 Subject: [PATCH 181/500] net: Add extra priv_flag support in netdevice This patch adds a flag in struct net_device which is an extension to priv_flags and is used to check the type of device. Change-Id: Ibb5a3f0c706e1b169b848aed7004aa4ea6d57069 Signed-off-by: Pavithra R Add GRE std support in device tree and priv_flags Added dts support and priv flags support for GRE and to check the type of device Change-Id: Ib05a32e9e5458c724c182187362116338d767169 Signed-off-by: ratheesh kannoth Signed-off-by: Pavithra R drivers: ifb: Add flag to identify the IFB interface. Add IFB flag in netdevice's ext priv flags and define an API to let other modules find out if the netdev is IFB or not. Change-Id: I6dbdae521240b4a991069c2330d893ff38aec68d Signed-off-by: Manish Verma Signed-off-by: pavir net: add IFF_EXT_MAPT flag in net_device priv_flags_ext Add IFF_EXT_MAPT flag in priv_flags_ext for MAP-T device. Change-Id: I8aa1715c4b9c62b88eee1b40412cf4e734b2a337 Signed-off-by: Suruchi Agarwal Signed-off-by: Murat Sezgin --- drivers/net/ifb.c | 1 + include/linux/netdevice.h | 35 ++++++++++++++++++++++++++++++++++- net/ipv4/ip_gre.c | 2 +- net/ipv6/ip6_gre.c | 4 +--- 4 files changed, 37 insertions(+), 5 deletions(-) --- a/drivers/net/ifb.c +++ b/drivers/net/ifb.c @@ -351,6 +351,7 @@ static void ifb_setup(struct net_device dev->flags |= IFF_NOARP; dev->flags &= ~IFF_MULTICAST; dev->priv_flags &= ~IFF_TX_SKB_SHARING; + dev->priv_flags_ext |= IFF_EXT_IFB; /* Mark the device as an IFB device. */ netif_keep_dst(dev); eth_hw_addr_random(dev); dev->needs_free_netdev = true; --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1781,6 +1781,32 @@ enum netdev_priv_flags { IFF_NO_IP_ALIGN = BIT_ULL(34), }; +/** + * enum netdev_priv_flags_ext - &struct net_device priv_flags_ext + * + * These flags are used to check for device type and can be + * set and used by the drivers + * + * @IFF_EXT_TUN_TAP: device is a TUN/TAP device + * @IFF_EXT_PPP_L2TPV2: device is a L2TPV2 device + * @IFF_EXT_PPP_L2TPV3: device is a L2TPV3 device + * @IFF_EXT_PPP_PPTP: device is a PPTP device + * @IFF_EXT_GRE_V4_TAP: device is a GRE IPv4 TAP device + * @IFF_EXT_GRE_V6_TAP: device is a GRE IPv6 TAP device + * @IFF_EXT_IFB: device is an IFB device + * @IFF_EXT_MAPT: device is an MAPT device + */ +enum netdev_priv_flags_ext { + IFF_EXT_TUN_TAP = 1<<0, + IFF_EXT_PPP_L2TPV2 = 1<<1, + IFF_EXT_PPP_L2TPV3 = 1<<2, + IFF_EXT_PPP_PPTP = 1<<3, + IFF_EXT_GRE_V4_TAP = 1<<4, + IFF_EXT_GRE_V6_TAP = 1<<5, + IFF_EXT_IFB = 1<<6, + IFF_EXT_MAPT = 1<<7, +}; + #define IFF_802_1Q_VLAN IFF_802_1Q_VLAN #define IFF_EBRIDGE IFF_EBRIDGE #define IFF_BONDING IFF_BONDING @@ -1901,6 +1927,8 @@ enum netdev_stat_type { * @xdp_features: XDP capability supported by the device * @priv_flags: Like 'flags' but invisible to userspace, * see if.h for the definitions + * @priv_flags_ext: Extension for 'priv_flags' + * * @gflags: Global flags ( kept as legacy ) * @padded: How much padding added by alloc_netdev() * @operstate: RFC2863 operstate @@ -2146,6 +2174,7 @@ struct net_device { unsigned int flags; xdp_features_t xdp_features; unsigned long long priv_flags; + unsigned int priv_flags_ext; const struct net_device_ops *netdev_ops; const struct xdp_metadata_ops *xdp_metadata_ops; int ifindex; @@ -4306,7 +4335,6 @@ static inline bool netif_dormant(const s return test_bit(__LINK_STATE_DORMANT, &dev->state); } - /** * netif_testing_on - mark device as under test. * @dev: network device @@ -5258,6 +5286,11 @@ static inline bool netif_is_failover_sla return dev->priv_flags & IFF_FAILOVER_SLAVE; } +static inline bool netif_is_ifb_dev(const struct net_device *dev) +{ + return dev->priv_flags_ext & IFF_EXT_IFB; +} + /* This device needs to keep skb dst for qdisc enqueue or ndo_start_xmit() */ static inline void netif_keep_dst(struct net_device *dev) { --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -828,7 +828,6 @@ static int ipgre_tunnel_ctl(struct net_d It allows to construct virtual multiprotocol broadcast "LAN" over the Internet, provided multicast routing is tuned. - I have no idea was this bicycle invented before me, so that I had to set ARPHRD_IPGRE to a random value. I have an impression, that Cisco could make something similar, @@ -1337,6 +1336,7 @@ static void ipgre_tap_setup(struct net_d dev->netdev_ops = &gre_tap_netdev_ops; dev->priv_flags &= ~IFF_TX_SKB_SHARING; dev->priv_flags |= IFF_LIVE_ADDR_CHANGE; + dev->priv_flags_ext |= IFF_EXT_GRE_V4_TAP; ip_tunnel_setup(dev, gre_tap_net_id); } --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c @@ -53,7 +53,6 @@ #include #include - static bool log_ecn_error = true; module_param(log_ecn_error, bool, 0644); MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN"); @@ -414,7 +413,6 @@ static void ip6gre_tunnel_uninit(struct netdev_put(dev, &t->dev_tracker); } - static int ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt, u8 type, u8 code, int offset, __be32 info) { @@ -1618,7 +1616,6 @@ static int __net_init ip6gre_init_net(st */ ign->fb_tunnel_dev->features |= NETIF_F_NETNS_LOCAL; - ip6gre_fb_tunnel_init(ign->fb_tunnel_dev); ign->fb_tunnel_dev->rtnl_link_ops = &ip6gre_link_ops; @@ -1941,6 +1938,7 @@ static void ip6gre_tap_setup(struct net_ dev->priv_flags &= ~IFF_TX_SKB_SHARING; dev->priv_flags |= IFF_LIVE_ADDR_CHANGE; + dev->priv_flags_ext |= IFF_EXT_GRE_V6_TAP; netif_keep_dst(dev); }