ice: Add PFCP filter support
Subsystems (17)
v2 cover ice: Add PFCP filter support
Add support for creating PFCP filters in switchdev mode. Add pfcp module that allows to create a PFCP-type netdev. The netdev then can be passed to tc when creating a filter to indicate that PFCP filter should be created.
To add a PFCP filter, a special netdev must be created and passed to tc command:
ip link add pfcp0 type pfcp
tc filter add dev eth0 ingress prio 1 flower pfcp_opts \
1:123/ff:fffffffffffffff0 skip_hw action mirred egress redirect dev pfcp0
Changes in iproute2 are required to be able to add the pfcp netdev and use pfcp_opts in tc (patchset will be submitted later).
ICE COMMS package is required as it contains PFCP profiles.
Part of this patchset modifies IP_TUNNEL_*_OPTs, which were previously stored in a __be16. All possible values have already been used, making it impossible to add new ones.
Alexander Lobakin (2):
ip_tunnel: use a separate struct to store tunnel params in the kernel
ip_tunnel: convert __be16 tunnel flags to bitmaps
Marcin Szycik (2):
ice: refactor ICE_TC_FLWR_FIELD_ENC_OPTS
ice: Add support for PFCP hardware offload in switchdev
Michal Swiatkowski (1):
pfcp: always set pfcp metadata
Wojciech Drewek (1):
pfcp: add PFCP module
drivers/net/Kconfig | 13 + drivers/net/Makefile | 1 + drivers/net/bareudp.c | 19 +- drivers/net/ethernet/intel/ice/ice_ddp.c | 9 + .../net/ethernet/intel/ice/ice_flex_type.h | 4 +- .../ethernet/intel/ice/ice_protocol_type.h | 12 + drivers/net/ethernet/intel/ice/ice_switch.c | 85 +++++ drivers/net/ethernet/intel/ice/ice_switch.h | 2 + drivers/net/ethernet/intel/ice/ice_tc_lib.c | 68 +++- drivers/net/ethernet/intel/ice/ice_tc_lib.h | 7 +- .../ethernet/mellanox/mlx5/core/en/tc_tun.h | 2 +- .../mellanox/mlx5/core/en/tc_tun_encap.c | 6 +- .../mellanox/mlx5/core/en/tc_tun_geneve.c | 12 +- .../mellanox/mlx5/core/en/tc_tun_gre.c | 9 +- .../mellanox/mlx5/core/en/tc_tun_vxlan.c | 9 +- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 15 +- .../ethernet/mellanox/mlxsw/spectrum_ipip.c | 62 ++-- .../ethernet/mellanox/mlxsw/spectrum_ipip.h | 2 +- .../ethernet/mellanox/mlxsw/spectrum_span.c | 10 +- .../ethernet/netronome/nfp/flower/action.c | 12 +- drivers/net/geneve.c | 46 ++- drivers/net/pfcp.c | 303 ++++++++++++++++++ drivers/net/vxlan/vxlan_core.c | 14 +- include/linux/netdevice.h | 7 +- include/net/dst_metadata.h | 10 +- include/net/flow_dissector.h | 2 +- include/net/gre.h | 59 ++-- include/net/ip6_tunnel.h | 4 +- include/net/ip_tunnels.h | 106 +++++- include/net/pfcp.h | 83 +++++ include/net/udp_tunnel.h | 4 +- include/uapi/linux/if_tunnel.h | 36 +++ include/uapi/linux/pkt_cls.h | 14 + net/bridge/br_vlan_tunnel.c | 5 +- net/core/filter.c | 20 +- net/core/flow_dissector.c | 12 +- net/ipv4/fou_bpf.c | 2 +- net/ipv4/gre_demux.c | 2 +- net/ipv4/ip_gre.c | 148 +++++---- net/ipv4/ip_tunnel.c | 92 ++++-- net/ipv4/ip_tunnel_core.c | 83 +++-- net/ipv4/ip_vti.c | 43 ++- net/ipv4/ipip.c | 33 +- net/ipv4/ipmr.c | 2 +- net/ipv4/udp_tunnel_core.c | 5 +- net/ipv6/addrconf.c | 3 +- net/ipv6/ip6_gre.c | 87 ++--- net/ipv6/ip6_tunnel.c | 14 +- net/ipv6/sit.c | 47 ++- net/netfilter/ipvs/ip_vs_core.c | 6 +- net/netfilter/ipvs/ip_vs_xmit.c | 20 +- net/netfilter/nft_tunnel.c | 45 +-- net/openvswitch/flow_netlink.c | 55 ++-- net/psample/psample.c | 26 +- net/sched/act_tunnel_key.c | 39 +-- net/sched/cls_flower.c | 134 +++++++- 56 files changed, 1501 insertions(+), 469 deletions(-) create mode 100644 drivers/net/pfcp.c create mode 100644 include/net/pfcp.h
Signature · 1 line
2.31.1
PATCH v2 3/6 pfcp: add PFCP module
From: Wojciech Drewek <[email protected]>
Packet Forwarding Control Protocol (PFCP) is a 3GPP Protocol used between the control plane and the user plane function. It is specified in TS 29.244[1].
Note that this module is not designed to support this Protocol in the kernel space. There is no support for parsing any PFCP messages. There is no API that could be used by any userspace daemon. Basically it does not support PFCP. This protocol is sophisticated and there is no need for implementing it in the kernel. The purpose of this module is to allow users to setup software and hardware offload of PFCP packets using tc tool.
When user requests to create a PFCP device, a new socket is created. The socket is set up with port number 8805 which is specific for PFCP [29.244 4.2.2]. This allow to receive PFCP request messages, response messages use other ports.
Note that only one PFCP netdev can be created.
Only IPv4 is supported at this time.
[1] https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=3111
---
v2: Fixed typos
--- drivers/net/Kconfig | 13 +++ drivers/net/Makefile | 1 + drivers/net/pfcp.c | 223 +++++++++++++++++++++++++++++++++++++++++++ include/net/pfcp.h | 13 +++ 4 files changed, 250 insertions(+) create mode 100644 drivers/net/pfcp.c create mode 100644 include/net/pfcp.h
drivers/net/Kconfig +13 -0
@@ -290,6 +290,19 @@ config GTP To compile this drivers as a module, choose M here: the module will be called gtp. +config PFCP + tristate "Packet Forwarding Control Protocol (PFCP)" + depends on INET + select NET_UDP_TUNNEL + help + This allows one to create PFCP virtual interfaces that allows to + set up software and hardware offload of PFCP packets. + Note that this module does not support PFCP protocol in the kernel space. + There is no support for parsing any PFCP messages. + + To compile this drivers as a module, choose M here: the module + will be called pfcp. + config AMT tristate "Automatic Multicast Tunneling (AMT)" depends on INET && IP_MULTICAST
drivers/net/Makefile +1 -0
@@ -37,6 +37,7 @@ obj-$(CONFIG_GENEVE) += geneve.o obj-$(CONFIG_BAREUDP) += bareudp.o obj-$(CONFIG_GTP) += gtp.o obj-$(CONFIG_NLMON) += nlmon.o +obj-$(CONFIG_PFCP) += pfcp.o obj-$(CONFIG_NET_VRF) += vrf.o obj-$(CONFIG_VSOCKMON) += vsockmon.o obj-$(CONFIG_MHI_NET) += mhi_net.o
drivers/net/pfcp.c new file +223 -0
223 lines not on this page · raw message
include/net/pfcp.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _PFCP_H_ +#define _PFCP_H_ + +#define PFCP_PORT 8805 + +static inline bool netif_is_pfcp (const struct net_device *dev) +{ +return dev->rtnl_link_ops && + !strcmp (dev->rtnl_link_ops->kind,"pfcp" ); +} + +#endif
Signature · 1 line
2.31.1
PATCH v2 4/6 pfcp: always set pfcp metadata
In reply to Marcin SzycikFrom: Michal Swiatkowski <[email protected]>
In PFCP receive path set metadata needed by flower code to do correct classification based on this metadata.
---
v2: Changed return type to void in pfcp_session_recv() and pfcp_node_recv()
--- drivers/net/pfcp.c | 82 ++++++++++++++++++++++++- include/net/ip_tunnels.h | 2 + include/net/pfcp.h | 70 +++++++++++++++++++++ include/uapi/linux/if_tunnel.h | 3 + include/uapi/linux/pkt_cls.h | 14 +++++ net/sched/cls_flower.c | 107 +++++++++++++++++++++++++++++++++ 6 files changed, 277 insertions(+), 1 deletion(-)
drivers/net/pfcp.c +81 -1
@@ -5,6 +5,7 @@* (C) 2022 by Wojciech Drewek <[email protected]> * * Author: Wojciech Drewek <[email protected]> +* Michal Swiatkowski <[email protected]> */ #include <linux/module.h>
@@ -22,6 +23,8 @@ struct pfcp_dev {struct socket *sock;struct net_device *dev;struct net *net; + +struct gro_cells gro_cells; };static unsigned int pfcp_net_id__read_mostly ;
@@ -30,6 +33,78 @@ struct pfcp_net {struct list_head pfcp_dev_list; }; +static void +pfcp_session_recv (struct pfcp_dev *pfcp,struct sk_buff *skb, +struct pfcp_metadata *md) +{ +struct pfcphdr_session *unparsed =pfcp_hdr_session (skb); + + md->seid = unparsed->seid; + md->type =PFCP_TYPE_SESSION ; +} + +static void +pfcp_node_recv (struct pfcp_dev *pfcp,struct sk_buff *skb, +struct pfcp_metadata *md) +{ + md->type =PFCP_TYPE_NODE ; +} + +static int pfcp_encap_recv (struct sock *sk,struct sk_buff *skb) +{ +IP_TUNNEL_DECLARE_FLAGS (flags) = { }; +struct metadata_dst *tun_dst; +struct pfcp_metadata *md; +struct pfcphdr *unparsed; +struct pfcp_dev *pfcp; + +if (unlikely (!pskb_may_pull (skb,PFCP_HLEN ))) + goto drop; + + pfcp =rcu_dereference_sk_user_data (sk); +if (unlikely (!pfcp)) + goto drop; + + unparsed =pfcp_hdr (skb); + +bitmap_zero (flags, __IP_TUNNEL_FLAG_NUM); + tun_dst =udp_tun_rx_dst (skb, sk->sk_family, flags,0 , +sizeof (*md)); +if (unlikely (!tun_dst)) + goto drop; + + md =ip_tunnel_info_opts (&tun_dst->u.tun_info); +if (unlikely (!md)) + goto drop; + +if (unparsed->flags &PFCP_SEID_FLAG ) +pfcp_session_recv (pfcp, skb, md); +else +pfcp_node_recv (pfcp, skb, md); + +__set_bit (IP_TUNNEL_PFCP_OPT_BIT , flags); +ip_tunnel_info_opts_set (&tun_dst->u.tun_info, md,sizeof (*md), + flags); + +if (unlikely (iptunnel_pull_header (skb,PFCP_HLEN , skb->protocol, + !net_eq (sock_net (sk), +dev_net (pfcp->dev))))) + goto drop; + +skb_dst_set (skb, (struct dst_entry *)tun_dst); + +skb_reset_network_header (skb); +skb_reset_mac_header (skb); + skb->dev = pfcp->dev; + +gro_cells_receive (&pfcp->gro_cells, skb); + +return 0 ; +drop: +kfree_skb (skb); +return 0 ; +} +static void pfcp_del_sock (struct pfcp_dev *pfcp) {udp_tunnel_sock_release (pfcp->sock);
@@ -40,6 +115,7 @@ static void pfcp_dev_uninit(struct net_device *dev) {struct pfcp_dev *pfcp =netdev_priv (dev); +gro_cells_destroy (&pfcp->gro_cells);pfcp_del_sock (pfcp); }
@@ -49,7 +125,7 @@ static int pfcp_dev_init(struct net_device *dev) pfcp->dev = dev; -return 0 ; +return gro_cells_init (&pfcp->gro_cells, dev); }static const struct net_device_ops pfcp_netdev_ops = {
@@ -95,6 +171,10 @@ static struct socket *pfcp_create_sock(struct pfcp_dev *pfcp)if (err)return ERR_PTR (err); + tuncfg.sk_user_data = pfcp; + tuncfg.encap_rcv = pfcp_encap_recv; + tuncfg.encap_type =1 ; +setup_udp_tunnel_sock (net, sock, &tuncfg);return sock;
include/net/ip_tunnels.h +2 -0
@@ -198,6 +198,7 @@ static inline void ip_tunnel_set_options_present(unsigned long *flags)__set_bit (IP_TUNNEL_VXLAN_OPT_BIT , flags);__set_bit (IP_TUNNEL_ERSPAN_OPT_BIT , flags);__set_bit (IP_TUNNEL_GTP_OPT_BIT , flags); +__set_bit (IP_TUNNEL_PFCP_OPT_BIT , flags); }static inline void ip_tunnel_clear_options_present (unsigned long *flags)
@@ -206,6 +207,7 @@ static inline void ip_tunnel_clear_options_present(unsigned long *flags)__clear_bit (IP_TUNNEL_VXLAN_OPT_BIT , flags);__clear_bit (IP_TUNNEL_ERSPAN_OPT_BIT , flags);__clear_bit (IP_TUNNEL_GTP_OPT_BIT , flags); +__clear_bit (IP_TUNNEL_PFCP_OPT_BIT , flags); }static inline bool ip_tunnel_is_options_present (const unsigned long *flags)
include/net/pfcp.h +70 -0
78 lines not on this page · raw message
include/uapi/linux/if_tunnel.h +3 -0
@@ -212,6 +212,9 @@ enum {IP_TUNNEL_VTI_BIT =16U ,IP_TUNNEL_SIT_ISATAP_BIT =IP_TUNNEL_VTI_BIT , +/* Flags starting from here are available only via new bitmap cmds */ +IP_TUNNEL_PFCP_OPT_BIT =17U ,/* OPTIONS_PRESENT */ + __IP_TUNNEL_FLAG_NUM, };
include/uapi/linux/pkt_cls.h +14 -0
@@ -629,6 +629,10 @@ enum {* TCA_FLOWER_KEY_ENC_OPT_GTP_ * attributes */ +TCA_FLOWER_KEY_ENC_OPTS_PFCP ,/* Nested +* TCA_FLOWER_KEY_ENC_IPT_PFCP +* attributes +*/ __TCA_FLOWER_KEY_ENC_OPTS_MAX, };
@@ -678,6 +682,16 @@ enum {#define TCA_FLOWER_KEY_ENC_OPT_GTP_MAX \ (__TCA_FLOWER_KEY_ENC_OPT_GTP_MAX - 1) +enum { +TCA_FLOWER_KEY_ENC_OPT_PFCP_UNSPEC , +TCA_FLOWER_KEY_ENC_OPT_PFCP_TYPE ,/* u8 */ +TCA_FLOWER_KEY_ENC_OPT_PFCP_SEID ,/* be64 */ + __TCA_FLOWER_KEY_ENC_OPT_PFCP_MAX, +}; + +#define TCA_FLOWER_KEY_ENC_OPT_PFCP_MAX \ + (__TCA_FLOWER_KEY_ENC_OPT_PFCP_MAX - 1) +enum {TCA_FLOWER_KEY_MPLS_OPTS_UNSPEC ,TCA_FLOWER_KEY_MPLS_OPTS_LSE ,
net/sched/cls_flower.c +107 -0
149 lines not on this page · raw message
Signature · 1 line
2.31.1
PATCH v2 5/6 ice: refactor ICE_TC_FLWR_FIELD_ENC_OPTS
In reply to Marcin SzycikFLOW_DISSECTOR_KEY_ENC_OPTS can be used for multiple headers, but currently it is treated as GTP-exclusive in ice. Rename ICE_TC_FLWR_FIELD_ENC_OPTS to ICE_TC_FLWR_FIELD_GTP_OPTS and check for tunnel type earlier. After this refactor, it is easier to add new headers using FLOW_DISSECTOR_KEY_ENC_OPTS
- instead of checking tunnel type in ice_tc_count_lkups() and ice_tc_fill_tunnel_outer(), it needs to be checked only once, in ice_parse_tunnel_attr().
--- drivers/net/ethernet/intel/ice/ice_tc_lib.c | 10 +++++----- drivers/net/ethernet/intel/ice/ice_tc_lib.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/ice/ice_tc_lib.c +5 -5
@@ -27,7 +27,7 @@ ice_tc_count_lkups(u32 flags, struct ice_tc_flower_lyr_2_4_hdrs *headers,if (flags &ICE_TC_FLWR_FIELD_ENC_DST_MAC ) lkups_cnt++; -if (flags &ICE_TC_FLWR_FIELD_ENC_OPTS ) +if (flags &ICE_TC_FLWR_FIELD_GTP_OPTS ) lkups_cnt++; if (flags & (ICE_TC_FLWR_FIELD_ENC_SRC_IPV4 |
@@ -220,8 +220,7 @@ ice_tc_fill_tunnel_outer(u32 flags, struct ice_tc_flower_fltr *fltr, i++; } -if (flags &ICE_TC_FLWR_FIELD_ENC_OPTS && - (fltr->tunnel_type ==TNL_GTPU || fltr->tunnel_type ==TNL_GTPC )) { +if (flags &ICE_TC_FLWR_FIELD_GTP_OPTS ) { list[i].type =ice_proto_type_from_tunnel (fltr->tunnel_type);if (fltr->gtp_pdu_info_masks.pdu_type) {
@@ -1305,7 +1304,8 @@ ice_parse_tunnel_attr(struct net_device *dev, struct flow_rule *rule, } } -if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_ENC_OPTS )) { +if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_ENC_OPTS ) && + (fltr->tunnel_type ==TNL_GTPU || fltr->tunnel_type ==TNL_GTPC )) {struct flow_match_enc_opts match;flow_rule_match_enc_opts (rule, &match);
@@ -1316,7 +1316,7 @@ ice_parse_tunnel_attr(struct net_device *dev, struct flow_rule *rule,memcpy (&fltr->gtp_pdu_info_masks, &match.mask->data[0 ],sizeof (struct gtp_pdu_session_info )); - fltr->flags |=ICE_TC_FLWR_FIELD_ENC_OPTS ; + fltr->flags |=ICE_TC_FLWR_FIELD_GTP_OPTS ; }return 0 ;
drivers/net/ethernet/intel/ice/ice_tc_lib.h +1 -1
@@ -22,7 +22,7 @@#define ICE_TC_FLWR_FIELD_ENC_SRC_L4_PORT BIT(15)#define ICE_TC_FLWR_FIELD_ENC_DST_MAC BIT(16)#define ICE_TC_FLWR_FIELD_ETH_TYPE_ID BIT(17) -#define ICE_TC_FLWR_FIELD_ENC_OPTS BIT(18) +#define ICE_TC_FLWR_FIELD_GTP_OPTS BIT(18)#define ICE_TC_FLWR_FIELD_CVLAN BIT(19)#define ICE_TC_FLWR_FIELD_PPPOE_SESSID BIT(20)#define ICE_TC_FLWR_FIELD_PPP_PROTO BIT(21)
Signature · 1 line
2.31.1
PATCH v2 1/6 ip_tunnel: use a separate struct to store tunnel params in the kernel
In reply to Marcin SzycikFrom: Alexander Lobakin <[email protected]>
Unlike IPv6 tunnels which use purely-kernel __ip6_tnl_parm structure to store params inside the kernel, IPv4 tunnel code uses the same ip_tunnel_parm which is being used to talk with the userspace. This makes it difficult to alter or add any fields or use a different format for whatever data.
Define struct ip_tunnel_parm_kern, a 1:1 copy of ip_tunnel_parm for now, and use it throughout the code. The two places where the latter is used to interact with the userspace, now do a conversion from one type to another, with manual field-by-field assignments. Must be done at once, since ip_tunnel::parms is being used in most of those places.
--- .../ethernet/mellanox/mlxsw/spectrum_ipip.c | 30 +++++++----- .../ethernet/mellanox/mlxsw/spectrum_ipip.h | 2 +- .../ethernet/mellanox/mlxsw/spectrum_span.c | 4 +- include/linux/netdevice.h | 7 +-- include/net/ip_tunnels.h | 22 +++++++-- net/ipv4/ip_gre.c | 17 ++++--- net/ipv4/ip_tunnel.c | 49 ++++++++++++++----- net/ipv4/ip_tunnel_core.c | 2 +- net/ipv4/ip_vti.c | 12 ++--- net/ipv4/ipip.c | 12 ++--- net/ipv4/ipmr.c | 2 +- net/ipv6/addrconf.c | 3 +- net/ipv6/sit.c | 42 ++++++++++------ 13 files changed, 130 insertions(+), 74 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c +17 -13
@@ -8,7 +8,7 @@#include "spectrum_ipip.h" #include "reg.h" -struct ip_tunnel_parm +struct ip_tunnel_parm_kern mlxsw_sp_ipip_netdev_parms4 (const struct net_device *ol_dev) {struct ip_tunnel *tun =netdev_priv (ol_dev);
@@ -24,7 +24,8 @@ mlxsw_sp_ipip_netdev_parms6(const struct net_device *ol_dev)return tun->parms; } -static bool mlxsw_sp_ipip_parms4_has_ikey (const struct ip_tunnel_parm *parms) +static bool +mlxsw_sp_ipip_parms4_has_ikey (const struct ip_tunnel_parm_kern *parms) {return !!(parms->i_flags &TUNNEL_KEY ); }
@@ -34,7 +35,8 @@ static bool mlxsw_sp_ipip_parms6_has_ikey(const struct __ip6_tnl_parm *parms)return !!(parms->i_flags &TUNNEL_KEY ); } -static bool mlxsw_sp_ipip_parms4_has_okey (const struct ip_tunnel_parm *parms) +static bool +mlxsw_sp_ipip_parms4_has_okey (const struct ip_tunnel_parm_kern *parms) {return !!(parms->o_flags &TUNNEL_KEY ); }
@@ -44,7 +46,7 @@ static bool mlxsw_sp_ipip_parms6_has_okey(const struct __ip6_tnl_parm *parms)return !!(parms->o_flags &TUNNEL_KEY ); } -static u32 mlxsw_sp_ipip_parms4_ikey (const struct ip_tunnel_parm *parms) +static u32 mlxsw_sp_ipip_parms4_ikey (const struct ip_tunnel_parm_kern *parms) {return mlxsw_sp_ipip_parms4_has_ikey (parms) ?be32_to_cpu (parms->i_key) :0 ;
@@ -56,7 +58,7 @@ static u32 mlxsw_sp_ipip_parms6_ikey(const struct __ip6_tnl_parm *parms) be32_to_cpu(parms->i_key) : 0; } -static u32 mlxsw_sp_ipip_parms4_okey (const struct ip_tunnel_parm *parms) +static u32 mlxsw_sp_ipip_parms4_okey (const struct ip_tunnel_parm_kern *parms) {return mlxsw_sp_ipip_parms4_has_okey (parms) ?be32_to_cpu (parms->o_key) :0 ;
@@ -69,7 +71,7 @@ static u32 mlxsw_sp_ipip_parms6_okey(const struct __ip6_tnl_parm *parms) }static union mlxsw_sp_l3addr -mlxsw_sp_ipip_parms4_saddr (const struct ip_tunnel_parm *parms) +mlxsw_sp_ipip_parms4_saddr (const struct ip_tunnel_parm_kern *parms) {return (union mlxsw_sp_l3addr ) { .addr4 = parms->iph.saddr }; }
@@ -81,7 +83,7 @@ mlxsw_sp_ipip_parms6_saddr(const struct __ip6_tnl_parm *parms) }static union mlxsw_sp_l3addr -mlxsw_sp_ipip_parms4_daddr (const struct ip_tunnel_parm *parms) +mlxsw_sp_ipip_parms4_daddr (const struct ip_tunnel_parm_kern *parms) {return (union mlxsw_sp_l3addr ) { .addr4 = parms->iph.daddr }; }
@@ -96,7 +98,7 @@ union mlxsw_sp_l3addr mlxsw_sp_ipip_netdev_saddr(enum mlxsw_sp_l3proto proto, const struct net_device *ol_dev) { - struct ip_tunnel_parm parms4; + struct ip_tunnel_parm_kern parms4;struct __ip6_tnl_parm parms6;switch (proto) {
@@ -115,7 +117,9 @@ mlxsw_sp_ipip_netdev_saddr(enum mlxsw_sp_l3proto proto,static __be32 mlxsw_sp_ipip_netdev_daddr4 (const struct net_device *ol_dev) { -struct ip_tunnel_parm parms4 =mlxsw_sp_ipip_netdev_parms4 (ol_dev); +struct ip_tunnel_parm_kern parms4; + + parms4 =mlxsw_sp_ipip_netdev_parms4 (ol_dev);return mlxsw_sp_ipip_parms4_daddr (&parms4).addr4; }
@@ -124,7 +128,7 @@ static union mlxsw_sp_l3addr mlxsw_sp_ipip_netdev_daddr(enum mlxsw_sp_l3proto proto, const struct net_device *ol_dev) { - struct ip_tunnel_parm parms4; + struct ip_tunnel_parm_kern parms4;struct __ip6_tnl_parm parms6;switch (proto) {
@@ -150,7 +154,7 @@ bool mlxsw_sp_l3addr_is_zero(union mlxsw_sp_l3addr addr)static struct mlxsw_sp_ipip_parms mlxsw_sp_ipip_netdev_parms_init_gre4 (const struct net_device *ol_dev) { -struct ip_tunnel_parm parms =mlxsw_sp_ipip_netdev_parms4 (ol_dev); +struct ip_tunnel_parm_kern parms =mlxsw_sp_ipip_netdev_parms4 (ol_dev);return (struct mlxsw_sp_ipip_parms ) { .proto =MLXSW_SP_L3_PROTO_IPV4 ,
@@ -187,8 +191,8 @@ mlxsw_sp_ipip_decap_config_gre4(struct mlxsw_sp *mlxsw_sp, {u16 rif_index =mlxsw_sp_ipip_lb_rif_index (ipip_entry->ol_lb);u16 ul_rif_id =mlxsw_sp_ipip_lb_ul_rif_id (ipip_entry->ol_lb); +struct ip_tunnel_parm_kern parms;char rtdp_pl[MLXSW_REG_RTDP_LEN ]; -struct ip_tunnel_parm parms;unsigned int type_check;bool has_ikey;u32 daddr4;
@@ -252,7 +256,7 @@ static struct mlxsw_sp_rif_ipip_lb_config mlxsw_sp_ipip_ol_loopback_config_gre4(struct mlxsw_sp *mlxsw_sp, const struct net_device *ol_dev) { - struct ip_tunnel_parm parms = mlxsw_sp_ipip_netdev_parms4(ol_dev); + struct ip_tunnel_parm_kern parms = mlxsw_sp_ipip_netdev_parms4(ol_dev);enum mlxsw_reg_ritr_loopback_ipip_type lb_ipipt; lb_ipipt = mlxsw_sp_ipip_parms4_has_okey(&parms) ?
drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.h +1 -1
@@ -9,7 +9,7 @@#include <linux/if_tunnel.h> #include <net/ip6_tunnel.h> -struct ip_tunnel_parm +struct ip_tunnel_parm_kern mlxsw_sp_ipip_netdev_parms4 (const struct net_device *ol_dev);struct __ip6_tnl_parm mlxsw_sp_ipip_netdev_parms6 (const struct net_device *ol_dev);
drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c +2 -2
@@ -413,8 +413,8 @@ mlxsw_sp_span_gretap4_route(const struct net_device *to_dev, __be32 *saddrp, __be32 *daddrp) {struct ip_tunnel *tun =netdev_priv (to_dev); +struct ip_tunnel_parm_kern parms;struct net_device *dev =NULL ; -struct ip_tunnel_parm parms;struct rtable *rt =NULL ;struct flowi4 fl4;
@@ -451,7 +451,7 @@ mlxsw_sp_span_entry_gretap4_parms(struct mlxsw_sp *mlxsw_sp,const struct net_device *to_dev, struct mlxsw_sp_span_parms *sparmsp) { - struct ip_tunnel_parm tparm = mlxsw_sp_ipip_netdev_parms4(to_dev); + struct ip_tunnel_parm_kern tparm = mlxsw_sp_ipip_netdev_parms4(to_dev);union mlxsw_sp_l3addr saddr = { .addr4 = tparm.iph.saddr };union mlxsw_sp_l3addr daddr = { .addr4 = tparm.iph.daddr };bool inherit_tos = tparm.iph.tos &0x1 ;
include/linux/netdevice.h +4 -3
@@ -59,7 +59,7 @@ struct device;struct ethtool_ops ;struct phy_device ;struct dsa_port ; -struct ip_tunnel_parm ; +struct ip_tunnel_parm_kern ;struct macsec_context ;struct macsec_ops ;struct netdev_name_node ;
@@ -1401,7 +1401,7 @@ struct netdev_net_notifier {* queue id bound to an AF_XDP socket. The flags field specifies if * only RX, only Tx, or both should be woken up using the flags * XDP_WAKEUP_RX and XDP_WAKEUP_TX. -* int (*ndo_tunnel_ctl)(struct net_device *dev, struct ip_tunnel_parm *p, +* int (*ndo_tunnel_ctl)(struct net_device *dev, struct ip_tunnel_parm_kern *p, * int cmd); * Add, change, delete or get information on an IPv4 tunnel. * struct net_device *(*ndo_get_peer_dev)(struct net_device *dev);
@@ -1642,7 +1642,8 @@ struct net_device_ops {int (*ndo_xsk_wakeup)(struct net_device *dev,u32 queue_id,u32 flags);int (*ndo_tunnel_ctl)(struct net_device *dev, -struct ip_tunnel_parm *p,int cmd); +struct ip_tunnel_parm_kern *p, +int cmd);struct net_device * (*ndo_get_peer_dev)(struct net_device *dev);int (*ndo_fill_forward_path)(struct net_device_path_ctx *ctx,struct net_device_path *path);
include/net/ip_tunnels.h +17 -5
@@ -109,6 +109,17 @@ struct ip_tunnel_prl_entry {struct metadata_dst ; +/* Kernel-side copy of ip_tunnel_parm */ +struct ip_tunnel_parm_kern { +char name[IFNAMSIZ ]; +int link; +__be16 i_flags; +__be16 o_flags; +__be32 i_key; +__be32 o_key; +struct iphdr iph; +}; +struct ip_tunnel {struct ip_tunnel __rcu *next;struct hlist_node hash_node;
@@ -135,7 +146,7 @@ struct ip_tunnel {struct dst_cache dst_cache; -struct ip_tunnel_parm parms; +struct ip_tunnel_parm_kern parms;int mlink;int encap_hlen;/* Encap header length (FOU,GUE) */
@@ -289,7 +300,8 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, const struct iphdr *tnl_params, const u8 protocol);void ip_md_tunnel_xmit (struct sk_buff *skb,struct net_device *dev,const u8 proto,int tunnel_hlen); -int ip_tunnel_ctl (struct net_device *dev,struct ip_tunnel_parm *p,int cmd); +int ip_tunnel_ctl (struct net_device *dev,struct ip_tunnel_parm_kern *p, +int cmd);int ip_tunnel_siocdevprivate (struct net_device *dev,struct ifreq *ifr,void __user *data,int cmd);int __ip_tunnel_change_mtu (struct net_device *dev,int new_mtu,bool strict);
@@ -305,16 +317,16 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb, const struct tnl_ptk_info *tpi, struct metadata_dst *tun_dst, bool log_ecn_error);int ip_tunnel_changelink (struct net_device *dev,struct nlattr *tb[], -struct ip_tunnel_parm *p,__u32 fwmark); +struct ip_tunnel_parm_kern *p,__u32 fwmark);int ip_tunnel_newlink (struct net_device *dev,struct nlattr *tb[], -struct ip_tunnel_parm *p,__u32 fwmark); +struct ip_tunnel_parm_kern *p,__u32 fwmark);void ip_tunnel_setup (struct net_device *dev,unsigned int net_id);bool ip_tunnel_netlink_encap_parms (struct nlattr *data[],struct ip_tunnel_encap *encap);void ip_tunnel_netlink_parms (struct nlattr *data[], -struct ip_tunnel_parm *parms); +struct ip_tunnel_parm_kern *parms);extern const struct header_ops ip_tunnel_header_ops;__be16 ip_tunnel_parse_protocol (const struct sk_buff *skb);
net/ipv4/ip_gre.c +9 -8
@@ -780,7 +780,8 @@ static void ipgre_link_update(struct net_device *dev, bool set_mtu) } } -static int ipgre_tunnel_ctl (struct net_device *dev,struct ip_tunnel_parm *p, +static int ipgre_tunnel_ctl (struct net_device *dev, +struct ip_tunnel_parm_kern *p,int cmd) {int err;
@@ -1124,7 +1125,7 @@ static int erspan_validate(struct nlattr *tb[], struct nlattr *data[],static int ipgre_netlink_parms (struct net_device *dev,struct nlattr *data[],struct nlattr *tb[], -struct ip_tunnel_parm *parms, +struct ip_tunnel_parm_kern *parms,__u32 *fwmark) {struct ip_tunnel *t =netdev_priv (dev);
@@ -1191,7 +1192,7 @@ static int ipgre_netlink_parms(struct net_device *dev,static int erspan_netlink_parms (struct net_device *dev,struct nlattr *data[],struct nlattr *tb[], -struct ip_tunnel_parm *parms, +struct ip_tunnel_parm_kern *parms,__u32 *fwmark) {struct ip_tunnel *t =netdev_priv (dev);
@@ -1350,7 +1351,7 @@ static int ipgre_newlink(struct net *src_net, struct net_device *dev, struct nlattr *tb[], struct nlattr *data[], struct netlink_ext_ack *extack) { - struct ip_tunnel_parm p; + struct ip_tunnel_parm_kern p;__u32 fwmark =0 ;int err;
@@ -1368,7 +1369,7 @@ static int erspan_newlink(struct net *src_net, struct net_device *dev, struct nlattr *tb[], struct nlattr *data[], struct netlink_ext_ack *extack) { - struct ip_tunnel_parm p; + struct ip_tunnel_parm_kern p;__u32 fwmark =0 ;int err;
@@ -1387,8 +1388,8 @@ static int ipgre_changelink(struct net_device *dev, struct nlattr *tb[], struct netlink_ext_ack *extack) {struct ip_tunnel *t =netdev_priv (dev); +struct ip_tunnel_parm_kern p;__u32 fwmark = t->fwmark; -struct ip_tunnel_parm p;int err; err =ipgre_newlink_encap_setup (dev, data);
@@ -1416,8 +1417,8 @@ static int erspan_changelink(struct net_device *dev, struct nlattr *tb[], struct netlink_ext_ack *extack) {struct ip_tunnel *t =netdev_priv (dev); +struct ip_tunnel_parm_kern p;__u32 fwmark = t->fwmark; -struct ip_tunnel_parm p;int err; err =ipgre_newlink_encap_setup (dev, data);
@@ -1489,7 +1490,7 @@ static size_t ipgre_get_size(const struct net_device *dev)static int ipgre_fill_info (struct sk_buff *skb,const struct net_device *dev) {struct ip_tunnel *t =netdev_priv (dev); -struct ip_tunnel_parm *p = &t->parms; +struct ip_tunnel_parm_kern *p = &t->parms;__be16 o_flags = p->o_flags; if (nla_put_u32(skb, IFLA_GRE_LINK, p->link) ||
net/ipv4/ip_tunnel.c +36 -13
121 lines not on this page · raw message
net/ipv4/ip_tunnel_core.c +1 -1
@@ -1116,7 +1116,7 @@ bool ip_tunnel_netlink_encap_parms(struct nlattr *data[],EXPORT_SYMBOL_GPL (ip_tunnel_netlink_encap_parms);void ip_tunnel_netlink_parms (struct nlattr *data[], -struct ip_tunnel_parm *parms) +struct ip_tunnel_parm_kern *parms) {if (data[IFLA_IPTUN_LINK ]) parms->link =nla_get_u32 (data[IFLA_IPTUN_LINK ]);
net/ipv4/ip_vti.c +6 -6
@@ -167,7 +167,7 @@ static netdev_tx_t vti_xmit(struct sk_buff *skb, struct net_device *dev, struct flowi *fl) {struct ip_tunnel *tunnel =netdev_priv (dev); -struct ip_tunnel_parm *parms = &tunnel->parms; +struct ip_tunnel_parm_kern *parms = &tunnel->parms;struct dst_entry *dst =skb_dst (skb);struct net_device *tdev;/* Device to other host */ int pkt_len = skb->len;
@@ -373,7 +373,7 @@ static int vti4_err(struct sk_buff *skb, u32 info) }static int -vti_tunnel_ctl (struct net_device *dev,struct ip_tunnel_parm *p,int cmd) +vti_tunnel_ctl (struct net_device *dev,struct ip_tunnel_parm_kern *p,int cmd) {int err =0 ;
@@ -529,7 +529,7 @@ static int vti_tunnel_validate(struct nlattr *tb[], struct nlattr *data[], }static void vti_netlink_parms (struct nlattr *data[], -struct ip_tunnel_parm *parms, +struct ip_tunnel_parm_kern *parms,__u32 *fwmark) {memset (parms,0 ,sizeof (*parms));
@@ -564,7 +564,7 @@ static int vti_newlink(struct net *src_net, struct net_device *dev, struct nlattr *tb[], struct nlattr *data[], struct netlink_ext_ack *extack) { - struct ip_tunnel_parm parms; + struct ip_tunnel_parm_kern parms;__u32 fwmark =0 ;vti_netlink_parms (data, &parms, &fwmark);
@@ -576,8 +576,8 @@ static int vti_changelink(struct net_device *dev, struct nlattr *tb[], struct netlink_ext_ack *extack) {struct ip_tunnel *t =netdev_priv (dev); +struct ip_tunnel_parm_kern p;__u32 fwmark = t->fwmark; -struct ip_tunnel_parm p;vti_netlink_parms (data, &p, &fwmark);return ip_tunnel_changelink (dev, tb, &p, fwmark);
@@ -604,7 +604,7 @@ static size_t vti_get_size(const struct net_device *dev)static int vti_fill_info (struct sk_buff *skb,const struct net_device *dev) {struct ip_tunnel *t =netdev_priv (dev); -struct ip_tunnel_parm *p = &t->parms; +struct ip_tunnel_parm_kern *p = &t->parms; if (nla_put_u32(skb, IFLA_VTI_LINK, p->link) || nla_put_be32(skb, IFLA_VTI_IKEY, p->i_key) ||
net/ipv4/ipip.c +6 -6
@@ -330,7 +330,7 @@ static bool ipip_tunnel_ioctl_verify_protocol(u8 ipproto) }static int -ipip_tunnel_ctl (struct net_device *dev,struct ip_tunnel_parm *p,int cmd) +ipip_tunnel_ctl (struct net_device *dev,struct ip_tunnel_parm_kern *p,int cmd) {if (cmd ==SIOCADDTUNNEL || cmd ==SIOCCHGTUNNEL ) { if (p->iph.version != 4 ||
@@ -405,8 +405,8 @@ static int ipip_tunnel_validate(struct nlattr *tb[], struct nlattr *data[], }static void ipip_netlink_parms (struct nlattr *data[], -struct ip_tunnel_parm *parms,bool *collect_md, -__u32 *fwmark) +struct ip_tunnel_parm_kern *parms, +bool *collect_md,__u32 *fwmark) {memset (parms,0 ,sizeof (*parms));
@@ -432,8 +432,8 @@ static int ipip_newlink(struct net *src_net, struct net_device *dev, struct netlink_ext_ack *extack) {struct ip_tunnel *t =netdev_priv (dev); -struct ip_tunnel_parm p;struct ip_tunnel_encap ipencap; +struct ip_tunnel_parm_kern p;__u32 fwmark =0 ;if (ip_tunnel_netlink_encap_parms (data, &ipencap)) {
@@ -452,8 +452,8 @@ static int ipip_changelink(struct net_device *dev, struct nlattr *tb[], struct netlink_ext_ack *extack) {struct ip_tunnel *t =netdev_priv (dev); -struct ip_tunnel_parm p;struct ip_tunnel_encap ipencap; +struct ip_tunnel_parm_kern p;bool collect_md;__u32 fwmark = t->fwmark;
@@ -510,7 +510,7 @@ static size_t ipip_get_size(const struct net_device *dev)static int ipip_fill_info (struct sk_buff *skb,const struct net_device *dev) {struct ip_tunnel *tunnel =netdev_priv (dev); -struct ip_tunnel_parm *parm = &tunnel->parms; +struct ip_tunnel_parm_kern *parm = &tunnel->parms; if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) || nla_put_in_addr(skb, IFLA_IPTUN_LOCAL, parm->iph.saddr) ||
net/ipv4/ipmr.c +1 -1
@@ -441,7 +441,7 @@ static bool ipmr_init_vif_indev(const struct net_device *dev)static struct net_device *ipmr_new_tunnel (struct net *net,struct vifctl *v) {struct net_device *tunnel_dev, *new_dev; -struct ip_tunnel_parm p = { }; +struct ip_tunnel_parm_kern p = { };int err; tunnel_dev =__dev_get_by_name (net,"tunl0" );
net/ipv6/addrconf.c +2 -1
@@ -63,6 +63,7 @@#include <linux/string.h> #include <linux/hash.h> +#include <net/ip_tunnels.h> #include <net/net_namespace.h> #include <net/sock.h> #include <net/snmp.h>
@@ -2839,7 +2840,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao)static int addrconf_set_sit_dstaddr (struct net *net,struct net_device *dev,struct in6_ifreq *ireq) { -struct ip_tunnel_parm p = { }; +struct ip_tunnel_parm_kern p = { };int err;if (!(ipv6_addr_type (&ireq->ifr6_addr) & IPV6_ADDR_COMPATv4))
net/ipv6/sit.c +28 -14
123 lines not on this page · raw message
Signature · 1 line
2.31.1
PATCH v2 6/6 ice: Add support for PFCP hardware offload in switchdev
In reply to Marcin SzycikAdd support for creating PFCP filters in switchdev mode. Add support for parsing PFCP-specific tc options: S flag and SEID.
To create a PFCP filter, a special netdev must be created and passed to tc command:
ip link add pfcp0 type pfcp
tc filter add dev eth0 ingress prio 1 flower pfcp_opts \
1:123/ff:fffffffffffffff0 skip_hw action mirred egress redirect dev pfcp0
Changes in iproute2 are required to be able to add the pfcp netdev and use pfcp_opts in tc.
ICE COMMS package is required to create a filter as it contains PFCP profiles.
--- drivers/net/ethernet/intel/ice/ice_ddp.c | 9 ++ .../net/ethernet/intel/ice/ice_flex_type.h | 4 +- .../ethernet/intel/ice/ice_protocol_type.h | 12 +++ drivers/net/ethernet/intel/ice/ice_switch.c | 85 +++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_switch.h | 2 + drivers/net/ethernet/intel/ice/ice_tc_lib.c | 58 +++++++++++-- drivers/net/ethernet/intel/ice/ice_tc_lib.h | 5 ++ 7 files changed, 168 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/ice/ice_ddp.c +9 -0
@@ -721,6 +721,12 @@ static bool ice_is_gtp_c_profile(u16 prof_idx) } } +static bool ice_is_pfcp_profile (u16 prof_idx) +{ +return prof_idx >=ICE_PROFID_IPV4_PFCP_NODE && + prof_idx <=ICE_PROFID_IPV6_PFCP_SESSION ; +} +/** * ice_get_sw_prof_type - determine switch profile type * @hw: pointer to the HW structure
@@ -738,6 +744,9 @@ static enum ice_prof_type ice_get_sw_prof_type(struct ice_hw *hw,if (ice_is_gtp_u_profile (prof_idx))return ICE_PROF_TUN_GTPU ; +if (ice_is_pfcp_profile (prof_idx)) +return ICE_PROF_TUN_PFCP ; +for (i =0 ; i < hw->blk[ICE_BLK_SW ].es.fvw; i++) {/* UDP tunnel will have UDP_OF protocol ID and VNI offset */ if (fv->ew[i].prot_id == (u8)ICE_PROT_UDP_OF &&
drivers/net/ethernet/intel/ice/ice_flex_type.h +3 -1
@@ -93,6 +93,7 @@ enum ice_tunnel_type {TNL_GRETAP ,TNL_GTPC ,TNL_GTPU , +TNL_PFCP , __TNL_TYPE_CNT,TNL_LAST =0xFF , TNL_ALL = 0xFF,
@@ -351,7 +352,8 @@ enum ice_prof_type {ICE_PROF_TUN_GRE =0x4 ,ICE_PROF_TUN_GTPU =0x8 ,ICE_PROF_TUN_GTPC =0x10 , -ICE_PROF_TUN_ALL =0x1E , +ICE_PROF_TUN_PFCP =0x20 , +ICE_PROF_TUN_ALL =0x3E , ICE_PROF_ALL = 0xFF, };
drivers/net/ethernet/intel/ice/ice_protocol_type.h +12 -0
@@ -43,6 +43,7 @@ enum ice_protocol_type {ICE_NVGRE ,ICE_GTP ,ICE_GTP_NO_PAY , +ICE_PFCP ,ICE_PPPOE ,ICE_L2TPV3 , ICE_VLAN_EX,
@@ -61,6 +62,7 @@ enum ice_sw_tunnel_type {ICE_SW_TUN_NVGRE ,ICE_SW_TUN_GTPU ,ICE_SW_TUN_GTPC , +ICE_SW_TUN_PFCP , ICE_ALL_TUNNELS /* All tunnel types including NVGRE */ };
@@ -202,6 +204,15 @@ struct ice_udp_gtp_hdr {u8 rsvrd; }; +struct ice_pfcp_hdr { +u8 flags; +u8 msg_type; +__be16 length; +__be64 seid; +__be32 seq; +u8 spare; +} __packed__aligned(__alignof__(u16)) ; +struct ice_pppoe_hdr {u8 rsrvd_ver_type;u8 rsrvd_code;
@@ -417,6 +428,7 @@ union ice_prot_hdr {struct ice_udp_tnl_hdr tnl_hdr;struct ice_nvgre_hdr nvgre_hdr;struct ice_udp_gtp_hdr gtp_hdr; +struct ice_pfcp_hdr pfcp_hdr;struct ice_pppoe_hdr pppoe_hdr;struct ice_l2tpv3_sess_hdr l2tpv3_sess_hdr;struct ice_hw_metadata metadata;
drivers/net/ethernet/intel/ice/ice_switch.c +85 -0
133 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_switch.h +2 -0
@@ -21,6 +21,8 @@#define ICE_PROFID_IPV6_GTPC_NO_TEID 45#define ICE_PROFID_IPV6_GTPU_TEID 46#define ICE_PROFID_IPV6_GTPU_IPV6_TCP_INNER 70 +#define ICE_PROFID_IPV4_PFCP_NODE 79 +#define ICE_PROFID_IPV6_PFCP_SESSION 82/* VSI context structure for add/get/update/free operations */ struct ice_vsi_ctx {
drivers/net/ethernet/intel/ice/ice_tc_lib.c +52 -6
106 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_tc_lib.h +5 -0
@@ -4,6 +4,8 @@#ifndef _ICE_TC_LIB_H_#define _ICE_TC_LIB_H_ +#include <net/pfcp.h> +#define ICE_TC_FLWR_FIELD_DST_MAC BIT(0)#define ICE_TC_FLWR_FIELD_SRC_MAC BIT(1)#define ICE_TC_FLWR_FIELD_VLAN BIT(2)
@@ -34,6 +36,7 @@#define ICE_TC_FLWR_FIELD_VLAN_PRIO BIT(27)#define ICE_TC_FLWR_FIELD_CVLAN_PRIO BIT(28)#define ICE_TC_FLWR_FIELD_VLAN_TPID BIT(29) +#define ICE_TC_FLWR_FIELD_PFCP_OPTS BIT(30)#define ICE_TC_FLOWER_MASK_32 0xFFFFFFFF
@@ -161,6 +164,8 @@ struct ice_tc_flower_fltr {__be32 tenant_id;struct gtp_pdu_session_info gtp_pdu_info_keys;struct gtp_pdu_session_info gtp_pdu_info_masks; +struct pfcp_metadata pfcp_meta_keys; +struct pfcp_metadata pfcp_meta_masks;u32 flags;u8 tunnel_type;struct ice_tc_flower_action action;
Signature · 1 line
2.31.1
PATCH v2 2/6 ip_tunnel: convert __be16 tunnel flags to bitmaps
In reply to Marcin SzycikFrom: Alexander Lobakin <[email protected]>
Historically, tunnel flags like TUNNEL_CSUM or TUNNEL_ERSPAN_OPT have been defined as __be16. Now all of those 16 bits are occupied and there's no more free space for new flags.
It can't be simply switched to a bigger container with no adjustments to the values, since it's an explicit Endian storage, and on LE systems (__be16)0x0001 equals to (__be64)0x0001000000000000.
We could probably define new 64-bit flags depending on the Endianness, i.e. (__be64)0x0001 on BE and (__be64)0x00010000... on LE, but that would introduce an Endianness dependency and spawn a ton of Sparse warnings. To mitigate them, all of those places which were adjusted with this change would be touched anyway, so why not define stuff properly if there's no choice.
Define IP_TUNNEL_*_BIT counterparts as a bit number instead of the value already coded and a fistful of <16 <-> bitmap> converters and helpers. The two flags which have a different bit position are SIT_ISATAP_64 and VTI_ISVTI_64, as they were defined not as __cpu_to_be16(), but as (__force __be16), i.e. had different positions on LE and BE. Now they have a strongly defined place. Change all __be16 fields which were used to store those flags, to IP_TUNNEL_DECLARE_FLAGS() -> DECLARE_BITMAP(__IP_TUNNEL_FLAG_NUM) -> unsigned long[1] for now, and replace all TUNNEL_* occurencies to their 64-bit bitmap counterparts. Use the converters in the places which talk to the userspace, hardware (NFP) or other hosts (GRE header). The rest must explicitly use the new flags only. This must be done at once, otherwise there will be too much conversions throughout the code in the intermediate commits.
Finally, disable the old __be16 flags for use in the kernel code (except for the two 'irregular' flags mentioned above), to prevent any accidental (mis)use of them. For the userspace, nothing is changed, only additions were made.
---
v2: Removed compile-time checks in nfp_fl_set_tun() (some compilers
couldn't handle __builtin_constant_p()). Fixed typos.
--- drivers/net/bareudp.c | 19 ++- .../ethernet/mellanox/mlx5/core/en/tc_tun.h | 2 +- .../mellanox/mlx5/core/en/tc_tun_encap.c | 6 +- .../mellanox/mlx5/core/en/tc_tun_geneve.c | 12 +- .../mellanox/mlx5/core/en/tc_tun_gre.c | 9 +- .../mellanox/mlx5/core/en/tc_tun_vxlan.c | 9 +- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 15 +- .../ethernet/mellanox/mlxsw/spectrum_ipip.c | 32 +++-- .../ethernet/mellanox/mlxsw/spectrum_span.c | 6 +- .../ethernet/netronome/nfp/flower/action.c | 12 +- drivers/net/geneve.c | 46 +++--- drivers/net/vxlan/vxlan_core.c | 14 +- include/net/dst_metadata.h | 10 +- include/net/flow_dissector.h | 2 +- include/net/gre.h | 59 ++++---- include/net/ip6_tunnel.h | 4 +- include/net/ip_tunnels.h | 90 ++++++++++-- include/net/udp_tunnel.h | 4 +- include/uapi/linux/if_tunnel.h | 33 +++++ net/bridge/br_vlan_tunnel.c | 5 +- net/core/filter.c | 20 +-- net/core/flow_dissector.c | 12 +- net/ipv4/fou_bpf.c | 2 +- net/ipv4/gre_demux.c | 2 +- net/ipv4/ip_gre.c | 131 +++++++++++------- net/ipv4/ip_tunnel.c | 51 ++++--- net/ipv4/ip_tunnel_core.c | 81 +++++++---- net/ipv4/ip_vti.c | 31 +++-- net/ipv4/ipip.c | 21 ++- net/ipv4/udp_tunnel_core.c | 5 +- net/ipv6/ip6_gre.c | 87 +++++++----- net/ipv6/ip6_tunnel.c | 14 +- net/ipv6/sit.c | 9 +- net/netfilter/ipvs/ip_vs_core.c | 6 +- net/netfilter/ipvs/ip_vs_xmit.c | 20 +-- net/netfilter/nft_tunnel.c | 45 +++--- net/openvswitch/flow_netlink.c | 55 ++++---- net/psample/psample.c | 26 ++-- net/sched/act_tunnel_key.c | 39 +++--- net/sched/cls_flower.c | 27 ++-- 40 files changed, 681 insertions(+), 392 deletions(-)
drivers/net/bareudp.c +13 -6
@@ -61,6 +61,7 @@ struct bareudp_dev {static int bareudp_udp_encap_recv (struct sock *sk,struct sk_buff *skb) {struct metadata_dst *tun_dst =NULL ; +IP_TUNNEL_DECLARE_FLAGS (key) = { };struct bareudp_dev *bareudp;unsigned short family;unsigned int len;
@@ -137,7 +138,10 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb) bareudp->dev->stats.rx_dropped++; goto drop; } - tun_dst =udp_tun_rx_dst (skb, family,TUNNEL_KEY ,0 ,0 ); + +__set_bit (IP_TUNNEL_KEY_BIT , key); + + tun_dst =udp_tun_rx_dst (skb, family, key,0 ,0 );if (!tun_dst) { bareudp->dev->stats.rx_dropped++; goto drop;
@@ -291,10 +295,10 @@ static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev,struct bareudp_dev *bareudp, const struct ip_tunnel_info *info) { + bool udp_sum = test_bit(IP_TUNNEL_CSUM_BIT, info->key.tun_flags);bool xnet = !net_eq (bareudp->net,dev_net (bareudp->dev));bool use_cache =ip_tunnel_dst_cache_usable (skb, info);struct socket *sock =rcu_dereference (bareudp->sock); -bool udp_sum = !!(info->key.tun_flags &TUNNEL_CSUM );const struct ip_tunnel_key *key = &info->key;struct rtable *rt;__be16 sport, df;
@@ -320,7 +324,8 @@ static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev, true); tos =ip_tunnel_ecn_encap (key->tos,ip_hdr (skb), skb); ttl = key->ttl; - df = key->tun_flags &TUNNEL_DONT_FRAGMENT ?htons (IP_DF ) :0 ; + df =test_bit (IP_TUNNEL_DONT_FRAGMENT_BIT , key->tun_flags) ? +htons (IP_DF ) :0 ;skb_scrub_packet (skb, xnet); err = -ENOSPC ;
@@ -342,7 +347,8 @@ static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev,udp_tunnel_xmit_skb (rt, sock->sk, skb, saddr, info->key.u.ipv4.dst, tos, ttl, df, sport, bareudp->port, !net_eq (bareudp->net,dev_net (bareudp->dev)), - !(info->key.tun_flags &TUNNEL_CSUM )); + !test_bit (IP_TUNNEL_CSUM_BIT , + info->key.tun_flags));return 0 ; free_dst:
@@ -354,10 +360,10 @@ static int bareudp6_xmit_skb(struct sk_buff *skb, struct net_device *dev,struct bareudp_dev *bareudp, const struct ip_tunnel_info *info) { + bool udp_sum = test_bit(IP_TUNNEL_CSUM_BIT, info->key.tun_flags);bool xnet = !net_eq (bareudp->net,dev_net (bareudp->dev));bool use_cache =ip_tunnel_dst_cache_usable (skb, info);struct socket *sock =rcu_dereference (bareudp->sock); -bool udp_sum = !!(info->key.tun_flags &TUNNEL_CSUM );const struct ip_tunnel_key *key = &info->key;struct dst_entry *dst =NULL ;struct in6_addr saddr, daddr;
@@ -404,7 +410,8 @@ static int bareudp6_xmit_skb(struct sk_buff *skb, struct net_device *dev,udp_tunnel6_xmit_skb (dst, sock->sk, skb, dev, &saddr, &daddr, prio, ttl, info->key.label, sport, bareudp->port, - !(info->key.tun_flags &TUNNEL_CSUM )); + !test_bit (IP_TUNNEL_CSUM_BIT , + info->key.tun_flags));return 0 ; free_dst:
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.h +1 -1
@@ -117,7 +117,7 @@ bool mlx5e_tc_tun_encap_info_equal_generic(struct mlx5e_encap_key *a,bool mlx5e_tc_tun_encap_info_equal_options (struct mlx5e_encap_key *a,struct mlx5e_encap_key *b, -__be16 tun_flags); +u32 tun_type);#endif /* CONFIG_MLX5_ESWITCH */ #endif //__MLX5_EN_TC_TUNNEL_H__
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c +3 -3
@@ -586,7 +586,7 @@ bool mlx5e_tc_tun_encap_info_equal_generic(struct mlx5e_encap_key *a,bool mlx5e_tc_tun_encap_info_equal_options (struct mlx5e_encap_key *a,struct mlx5e_encap_key *b, -__be16 tun_flags) +u32 tun_type) {struct ip_tunnel_info *a_info;struct ip_tunnel_info *b_info;
@@ -595,8 +595,8 @@ bool mlx5e_tc_tun_encap_info_equal_options(struct mlx5e_encap_key *a,if (!mlx5e_tc_tun_encap_info_equal_generic (a, b))return false; - a_has_opts = !!(a->ip_tun_key->tun_flags & tun_flags); - b_has_opts = !!(b->ip_tun_key->tun_flags & tun_flags); + a_has_opts =test_bit (tun_type, a->ip_tun_key->tun_flags); + b_has_opts =test_bit (tun_type, b->ip_tun_key->tun_flags);/* keys are equal when both don't have any options attached */ if (!a_has_opts && !b_has_opts)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c +7 -5
@@ -106,12 +106,13 @@ static int mlx5e_gen_ip_tunnel_header_geneve(char buf[],memset (geneveh,0 ,sizeof (*geneveh)); geneveh->ver =MLX5E_GENEVE_VER ; geneveh->opt_len = tun_info->options_len /4 ; - geneveh->oam = !!(tun_info->key.tun_flags &TUNNEL_OAM ); - geneveh->critical = !!(tun_info->key.tun_flags &TUNNEL_CRIT_OPT ); + geneveh->oam =test_bit (IP_TUNNEL_OAM_BIT , tun_info->key.tun_flags); + geneveh->critical =test_bit (IP_TUNNEL_CRIT_OPT_BIT , + tun_info->key.tun_flags);mlx5e_tunnel_id_to_vni (tun_info->key.tun_id, geneveh->vni); geneveh->proto_type =htons (ETH_P_TEB ); -if (tun_info->key.tun_flags &TUNNEL_GENEVE_OPT ) { +if (test_bit (IP_TUNNEL_GENEVE_OPT_BIT , tun_info->key.tun_flags)) {if (!geneveh->opt_len)return -EOPNOTSUPP ;ip_tunnel_info_opts_get (geneveh->options, tun_info);
@@ -188,7 +189,7 @@ static int mlx5e_tc_tun_parse_geneve_options(struct mlx5e_priv *priv,/* make sure that we're talking about GENEVE options */ -if (enc_opts.key->dst_opt_type !=TUNNEL_GENEVE_OPT ) { +if (enc_opts.key->dst_opt_type !=IP_TUNNEL_GENEVE_OPT_BIT ) {NL_SET_ERR_MSG_MOD (extack,"Matching on GENEVE options: option type is not GENEVE" ); netdev_warn(priv->netdev,
@@ -337,7 +338,8 @@ static int mlx5e_tc_tun_parse_geneve(struct mlx5e_priv *priv,static bool mlx5e_tc_tun_encap_info_equal_geneve (struct mlx5e_encap_key *a,struct mlx5e_encap_key *b) { -return mlx5e_tc_tun_encap_info_equal_options (a, b,TUNNEL_GENEVE_OPT ); +return mlx5e_tc_tun_encap_info_equal_options (a, b, +IP_TUNNEL_GENEVE_OPT_BIT ); }struct mlx5e_tc_tunnel geneve_tunnel = {
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_gre.c +7 -2
@@ -31,12 +31,17 @@ static int mlx5e_gen_ip_tunnel_header_gretap(char buf[],const struct ip_tunnel_key *tun_key = &e->tun_info->key;struct gre_base_hdr *greh = (struct gre_base_hdr *)(buf);__be32 tun_id =tunnel_id_to_key32 (tun_key->tun_id); +IP_TUNNEL_DECLARE_FLAGS (unsupp) = { };int hdr_len; *ip_proto =IPPROTO_GRE ;/* the HW does not calculate GRE csum or sequences */ -if (tun_key->tun_flags & (TUNNEL_CSUM |TUNNEL_SEQ )) +__set_bit (IP_TUNNEL_CSUM_BIT , unsupp); +__set_bit (IP_TUNNEL_SEQ_BIT , unsupp); + +if (bitmap_and (unsupp, tun_key->tun_flags, unsupp, + __IP_TUNNEL_FLAG_NUM))return -EOPNOTSUPP ; greh->protocol =htons (ETH_P_TEB );
@@ -44,7 +49,7 @@ static int mlx5e_gen_ip_tunnel_header_gretap(char buf[],/* GRE key */ hdr_len =mlx5e_tc_tun_calc_hlen_gretap (e); greh->flags =gre_tnl_flags_to_gre_flags (tun_key->tun_flags); -if (tun_key->tun_flags &TUNNEL_KEY ) { +if (test_bit (IP_TUNNEL_KEY_BIT , tun_key->tun_flags)) {__be32 *ptr = (__be32 *)(((u8 *)greh) + hdr_len -4 ); *ptr = tun_id; }
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c +5 -4
@@ -90,7 +90,7 @@ static int mlx5e_gen_ip_tunnel_header_vxlan(char buf[],const struct vxlan_metadata *md;struct vxlanhdr *vxh; -if ((tun_key->tun_flags &TUNNEL_VXLAN_OPT ) && +if (test_bit (IP_TUNNEL_VXLAN_OPT_BIT , tun_key->tun_flags) && e->tun_info->options_len !=sizeof (*md))return -EOPNOTSUPP ; vxh = (struct vxlanhdr *)((char *)udp +sizeof (struct udphdr ));
@@ -99,7 +99,7 @@ static int mlx5e_gen_ip_tunnel_header_vxlan(char buf[], udp->dest = tun_key->tp_dst; vxh->vx_flags =VXLAN_HF_VNI ; vxh->vx_vni =vxlan_vni_field (tun_id); -if (tun_key->tun_flags &TUNNEL_VXLAN_OPT ) { +if (test_bit (IP_TUNNEL_VXLAN_OPT_BIT , tun_key->tun_flags)) { md =ip_tunnel_info_opts (e->tun_info);vxlan_build_gbp_hdr (vxh, md); }
@@ -125,7 +125,7 @@ static int mlx5e_tc_tun_parse_vxlan_gbp_option(struct mlx5e_priv *priv,return -EOPNOTSUPP ; } -if (enc_opts.key->dst_opt_type !=TUNNEL_VXLAN_OPT ) { +if (enc_opts.key->dst_opt_type !=IP_TUNNEL_VXLAN_OPT_BIT ) {NL_SET_ERR_MSG_MOD (extack,"Wrong VxLAN option type: not GBP" );return -EOPNOTSUPP ; }
@@ -208,7 +208,8 @@ static int mlx5e_tc_tun_parse_vxlan(struct mlx5e_priv *priv,static bool mlx5e_tc_tun_encap_info_equal_vxlan (struct mlx5e_encap_key *a,struct mlx5e_encap_key *b) { -return mlx5e_tc_tun_encap_info_equal_options (a, b,TUNNEL_VXLAN_OPT ); +return mlx5e_tc_tun_encap_info_equal_options (a, b, +IP_TUNNEL_VXLAN_OPT_BIT ); }static int mlx5e_tc_tun_get_remote_ifindex (struct net_device *mirred_dev)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +11 -4
@@ -5385,6 +5385,7 @@ static bool mlx5e_tc_restore_tunnel(struct mlx5e_priv *priv, struct sk_buff *skbstruct mlx5_eswitch *esw = priv->mdev->priv.eswitch;struct tunnel_match_enc_opts enc_opts = {};struct mlx5_rep_uplink_priv *uplink_priv; +IP_TUNNEL_DECLARE_FLAGS (flags) = { };struct mlx5e_rep_priv *uplink_rpriv;struct metadata_dst *tun_dst;struct tunnel_match_key key;
@@ -5392,6 +5393,8 @@ static bool mlx5e_tc_restore_tunnel(struct mlx5e_priv *priv, struct sk_buff *skbstruct net_device *dev;int err; +__set_bit (IP_TUNNEL_KEY_BIT , flags); + enc_opts_id = tunnel_id &ENC_OPTS_BITS_MASK ; tun_id = tunnel_id >>ENC_OPTS_BITS ;
@@ -5424,14 +5427,14 @@ static bool mlx5e_tc_restore_tunnel(struct mlx5e_priv *priv, struct sk_buff *skbcase FLOW_DISSECTOR_KEY_IPV4_ADDRS : tun_dst =__ip_tun_set_dst (key.enc_ipv4.src, key.enc_ipv4.dst, key.enc_ip.tos, key.enc_ip.ttl, - key.enc_tp.dst,TUNNEL_KEY , + key.enc_tp.dst, flags,key32_to_tunnel_id (key.enc_key_id.keyid), enc_opts.key.len);break ;case FLOW_DISSECTOR_KEY_IPV6_ADDRS : tun_dst =__ipv6_tun_set_dst (&key.enc_ipv6.src, &key.enc_ipv6.dst, key.enc_ip.tos, key.enc_ip.ttl, - key.enc_tp.dst,0 ,TUNNEL_KEY , + key.enc_tp.dst,0 , flags,key32_to_tunnel_id (key.enc_key_id.keyid), enc_opts.key.len);break ;
@@ -5449,11 +5452,15 @@ static bool mlx5e_tc_restore_tunnel(struct mlx5e_priv *priv, struct sk_buff *skb tun_dst->u.tun_info.key.tp_src = key.enc_tp.src; -if (enc_opts.key.len) +if (enc_opts.key.len) { +bitmap_zero (flags, __IP_TUNNEL_FLAG_NUM); +__set_bit (enc_opts.key.dst_opt_type, flags); +ip_tunnel_info_opts_set (&tun_dst->u.tun_info, enc_opts.key.data, enc_opts.key.len, - enc_opts.key.dst_opt_type); + flags); + }skb_dst_set (skb, (struct dst_entry *)tun_dst); dev =dev_get_by_index (&init_net, key.filter_ifindex);
drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c +22 -10
@@ -27,23 +27,23 @@ mlxsw_sp_ipip_netdev_parms6(const struct net_device *ol_dev)static bool mlxsw_sp_ipip_parms4_has_ikey (const struct ip_tunnel_parm_kern *parms) { -return !!(parms->i_flags &TUNNEL_KEY ); +return test_bit (IP_TUNNEL_KEY_BIT , parms->i_flags); }static bool mlxsw_sp_ipip_parms6_has_ikey (const struct __ip6_tnl_parm *parms) { -return !!(parms->i_flags &TUNNEL_KEY ); +return test_bit (IP_TUNNEL_KEY_BIT , parms->i_flags); }static bool mlxsw_sp_ipip_parms4_has_okey (const struct ip_tunnel_parm_kern *parms) { -return !!(parms->o_flags &TUNNEL_KEY ); +return test_bit (IP_TUNNEL_KEY_BIT , parms->o_flags); }static bool mlxsw_sp_ipip_parms6_has_okey (const struct __ip6_tnl_parm *parms) { -return !!(parms->o_flags &TUNNEL_KEY ); +return test_bit (IP_TUNNEL_KEY_BIT , parms->o_flags); }static u32 mlxsw_sp_ipip_parms4_ikey (const struct ip_tunnel_parm_kern *parms)
@@ -242,12 +242,18 @@ static bool mlxsw_sp_ipip_can_offload_gre4(const struct mlxsw_sp *mlxsw_sp, const struct net_device *ol_dev) {struct ip_tunnel *tunnel =netdev_priv (ol_dev); -__be16 okflags =TUNNEL_KEY ;/* We can't offload any other features. */ bool inherit_ttl = tunnel->parms.iph.ttl ==0 ;bool inherit_tos = tunnel->parms.iph.tos &0x1 ; +IP_TUNNEL_DECLARE_FLAGS (okflags) = { }; +IP_TUNNEL_DECLARE_FLAGS (filter); -return (tunnel->parms.i_flags & ~okflags) ==0 && - (tunnel->parms.o_flags & ~okflags) ==0 && +/* We can't offload any other features. */ +__set_bit (IP_TUNNEL_KEY_BIT , okflags); + +return !bitmap_andnot (filter, tunnel->parms.i_flags, okflags, + __IP_TUNNEL_FLAG_NUM) && + !bitmap_andnot (filter, tunnel->parms.o_flags, okflags, + __IP_TUNNEL_FLAG_NUM) && inherit_ttl && inherit_tos &&mlxsw_sp_ipip_tunnel_complete (MLXSW_SP_L3_PROTO_IPV4 , ol_dev); }
@@ -443,10 +449,16 @@ static bool mlxsw_sp_ipip_can_offload_gre6(const struct mlxsw_sp *mlxsw_sp,struct __ip6_tnl_parm tparm =mlxsw_sp_ipip_netdev_parms6 (ol_dev);bool inherit_tos = tparm.flags &IP6_TNL_F_USE_ORIG_TCLASS ;bool inherit_ttl = tparm.hop_limit ==0 ; -__be16 okflags =TUNNEL_KEY ;/* We can't offload any other features. */ +IP_TUNNEL_DECLARE_FLAGS (okflags) = { }; +IP_TUNNEL_DECLARE_FLAGS (filter); + +/* We can't offload any other features. */ +__set_bit (IP_TUNNEL_KEY_BIT , okflags); -return (tparm.i_flags & ~okflags) ==0 && - (tparm.o_flags & ~okflags) ==0 && +return !bitmap_andnot (filter, tparm.i_flags, okflags, + __IP_TUNNEL_FLAG_NUM) && + !bitmap_andnot (filter, tparm.o_flags, okflags, + __IP_TUNNEL_FLAG_NUM) && inherit_ttl && inherit_tos &&mlxsw_sp_ipip_tunnel_complete (MLXSW_SP_L3_PROTO_IPV6 , ol_dev); }
drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c +4 -2
@@ -461,7 +461,8 @@ mlxsw_sp_span_entry_gretap4_parms(struct mlxsw_sp *mlxsw_sp, if (!(to_dev->flags & IFF_UP) || /* Reject tunnels with GRE keys, checksums, etc. */ - tparm.i_flags || tparm.o_flags || + !bitmap_empty(tparm.i_flags, __IP_TUNNEL_FLAG_NUM) || + !bitmap_empty(tparm.o_flags, __IP_TUNNEL_FLAG_NUM) || /* Require a fixed TTL and a TOS copied from the mirrored packet. */ inherit_ttl || !inherit_tos ||/* A destination address may not be "any". */
@@ -565,7 +566,8 @@ mlxsw_sp_span_entry_gretap6_parms(struct mlxsw_sp *mlxsw_sp, if (!(to_dev->flags & IFF_UP) || /* Reject tunnels with GRE keys, checksums, etc. */ - tparm.i_flags || tparm.o_flags || + !bitmap_empty(tparm.i_flags, __IP_TUNNEL_FLAG_NUM) || + !bitmap_empty(tparm.o_flags, __IP_TUNNEL_FLAG_NUM) || /* Require a fixed TTL and a TOS copied from the mirrored packet. */ inherit_ttl || !inherit_tos ||/* A destination address may not be "any". */
drivers/net/ethernet/netronome/nfp/flower/action.c +6 -6
@@ -410,6 +410,7 @@ nfp_fl_set_tun(struct nfp_app *app, struct nfp_fl_set_tun *set_tun,u32 tmp_set_ip_tun_type_index =0 ;/* Currently support one pre-tunnel so index is always 0. */ int pretun_idx =0 ; +__be16 tun_flags;if (!IS_ENABLED (CONFIG_IPV6 ) && ipv6)return -EOPNOTSUPP ;
@@ -417,9 +418,6 @@ nfp_fl_set_tun(struct nfp_app *app, struct nfp_fl_set_tun *set_tun,if (ipv6 && !(priv->flower_ext_feats &NFP_FL_FEATS_IPV6_TUN ))return -EOPNOTSUPP ; -BUILD_BUG_ON (NFP_FL_TUNNEL_CSUM !=TUNNEL_CSUM || -NFP_FL_TUNNEL_KEY !=TUNNEL_KEY || -NFP_FL_TUNNEL_GENEVE_OPT !=TUNNEL_GENEVE_OPT );if (ip_tun->options_len && (tun_type !=NFP_FL_TUNNEL_GENEVE || !(priv->flower_ext_feats &NFP_FL_FEATS_GENEVE_OPT ))) {
@@ -427,7 +425,9 @@ nfp_fl_set_tun(struct nfp_app *app, struct nfp_fl_set_tun *set_tun,return -EOPNOTSUPP ; } -if (ip_tun->key.tun_flags & ~NFP_FL_SUPPORTED_UDP_TUN_FLAGS ) { + tun_flags =ip_tunnel_flags_to_be16 (ip_tun->key.tun_flags); +if (!ip_tunnel_flags_is_be16_compat (ip_tun->key.tun_flags) || + (tun_flags & ~NFP_FL_SUPPORTED_UDP_TUN_FLAGS )) {NL_SET_ERR_MSG_MOD (extack,"unsupported offload: loaded firmware does not support tunnel flag offload" );return -EOPNOTSUPP ;
@@ -442,7 +442,7 @@ nfp_fl_set_tun(struct nfp_app *app, struct nfp_fl_set_tun *set_tun,FIELD_PREP (NFP_FL_PRE_TUN_INDEX , pretun_idx); set_tun->tun_type_index =cpu_to_be32 (tmp_set_ip_tun_type_index); -if (ip_tun->key.tun_flags &NFP_FL_TUNNEL_KEY ) +if (tun_flags &NFP_FL_TUNNEL_KEY ) set_tun->tun_id = ip_tun->key.tun_id;if (ip_tun->key.ttl) {
@@ -486,7 +486,7 @@ nfp_fl_set_tun(struct nfp_app *app, struct nfp_fl_set_tun *set_tun, } set_tun->tos = ip_tun->key.tos; - set_tun->tun_flags = ip_tun->key.tun_flags; + set_tun->tun_flags = tun_flags;if (tun_type ==NFP_FL_TUNNEL_GENEVE ) { set_tun->tun_proto =htons (ETH_P_TEB );
drivers/net/geneve.c +29 -17
132 lines not on this page · raw message
drivers/net/vxlan/vxlan_core.c +9 -5
@@ -1509,7 +1509,8 @@ static void vxlan_parse_gbp_hdr(struct vxlanhdr *unparsed, tun_dst = (struct metadata_dst *)skb_dst (skb);if (tun_dst) { - tun_dst->u.tun_info.key.tun_flags |=TUNNEL_VXLAN_OPT ; +__set_bit (IP_TUNNEL_VXLAN_OPT_BIT , + tun_dst->u.tun_info.key.tun_flags); tun_dst->u.tun_info.options_len =sizeof (*md); }if (gbp->dont_learn)
@@ -1669,9 +1670,11 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) goto drop;if (vxlan_collect_metadata (vs)) { +IP_TUNNEL_DECLARE_FLAGS (flags) = { };struct metadata_dst *tun_dst; - tun_dst =udp_tun_rx_dst (skb,vxlan_get_sk_family (vs),TUNNEL_KEY , +__set_bit (IP_TUNNEL_KEY_BIT , flags); + tun_dst =udp_tun_rx_dst (skb,vxlan_get_sk_family (vs), flags,key32_to_tunnel_id (vni),sizeof (*md));if (!tun_dst)
@@ -2459,7 +2462,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, vni =tunnel_id_to_key32 (info->key.tun_id); ifindex =0 ; dst_cache = &info->dst_cache; -if (info->key.tun_flags &TUNNEL_VXLAN_OPT ) { +if (test_bit (IP_TUNNEL_VXLAN_OPT_BIT , info->key.tun_flags)) {if (info->options_len <sizeof (*md)) goto drop; md =ip_tunnel_info_opts (info);
@@ -2469,7 +2472,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,#if IS_ENABLED (CONFIG_IPV6 ) label = info->key.label;#endif - udp_sum = !!(info->key.tun_flags &TUNNEL_CSUM ); + udp_sum =test_bit (IP_TUNNEL_CSUM_BIT , info->key.tun_flags); } src_port =udp_flow_src_port (dev_net (dev), skb, vxlan->cfg.port_min, vxlan->cfg.port_max, true);
@@ -2511,7 +2514,8 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, old_iph->frag_off & htons(IP_DF))) df =htons (IP_DF ); } - }else if (info->key.tun_flags &TUNNEL_DONT_FRAGMENT ) { + }else if (test_bit (IP_TUNNEL_DONT_FRAGMENT_BIT , + info->key.tun_flags)) { df =htons (IP_DF ); }
include/net/dst_metadata.h +5 -5
@@ -198,7 +198,7 @@ static inline struct metadata_dst *__ip_tun_set_dst(__be32 saddr,__be32 daddr, __u8 tos, __u8 ttl, __be16 tp_dst, - __be16 flags, + const unsigned long *flags, __be64 tunnel_id, int md_size) {
@@ -215,7 +215,7 @@ static inline struct metadata_dst *__ip_tun_set_dst(__be32 saddr, }static inline struct metadata_dst *ip_tun_rx_dst (struct sk_buff *skb, -__be16 flags, +const unsigned long *flags,__be64 tunnel_id,int md_size) {
@@ -230,7 +230,7 @@ static inline struct metadata_dst *__ipv6_tun_set_dst(const struct in6_addr *sad __u8 tos, __u8 ttl, __be16 tp_dst, __be32 label, - __be16 flags, + const unsigned long *flags, __be64 tunnel_id, int md_size) {
@@ -243,7 +243,7 @@ static inline struct metadata_dst *__ipv6_tun_set_dst(const struct in6_addr *sad info = &tun_dst->u.tun_info; info->mode =IP_TUNNEL_INFO_IPV6 ; - info->key.tun_flags = flags; +bitmap_copy (info->key.tun_flags, flags, __IP_TUNNEL_FLAG_NUM); info->key.tun_id = tunnel_id; info->key.tp_src =0 ; info->key.tp_dst = tp_dst;
@@ -259,7 +259,7 @@ static inline struct metadata_dst *__ipv6_tun_set_dst(const struct in6_addr *sad }static inline struct metadata_dst *ipv6_tun_rx_dst (struct sk_buff *skb, -__be16 flags, +const unsigned long *flags,__be64 tunnel_id,int md_size) {
include/net/flow_dissector.h +1 -1
@@ -97,7 +97,7 @@ struct flow_dissector_key_enc_opts {* here but seems difficult to #include */ u8 len; -__be16 dst_opt_type; +u32 dst_opt_type; };struct flow_dissector_key_keyid {
include/net/gre.h +31 -28
116 lines not on this page · raw message
include/net/ip6_tunnel.h +2 -2
@@ -30,8 +30,8 @@ struct __ip6_tnl_parm {struct in6_addr laddr;/* local tunnel end-point address */ struct in6_addr raddr;/* remote tunnel end-point address */ -__be16 i_flags; -__be16 o_flags; +IP_TUNNEL_DECLARE_FLAGS (i_flags); +IP_TUNNEL_DECLARE_FLAGS (o_flags);__be32 i_key;__be32 o_key;
include/net/ip_tunnels.h +76 -14
164 lines not on this page · raw message
include/net/udp_tunnel.h +2 -2
@@ -162,8 +162,8 @@ int udp_tunnel6_xmit_skb(struct dst_entry *dst, struct sock *sk,void udp_tunnel_sock_release (struct socket *sock);struct metadata_dst *udp_tun_rx_dst (struct sk_buff *skb,unsigned short family, -__be16 flags,__be64 tunnel_id, -int md_size); +const unsigned long *flags, +__be64 tunnel_id,int md_size);#ifdef CONFIG_INET static inline int udp_tunnel_handle_offloads (struct sk_buff *skb,bool udp_csum)
include/uapi/linux/if_tunnel.h +33 -0
@@ -161,6 +161,14 @@ enum {#define IFLA_VTI_MAX (__IFLA_VTI_MAX - 1) +#ifndef __KERNEL__ +/* Historically, tunnel flags have been defined as __be16 and now there are +* no free bits left. It is strongly advised to switch the already existing +* userspace code to u32/BIGINT and the new *_BIT definitions from down below, +* as __be16 can't be simply cast to a wider type on LE systems. All new +* flags and code must use *_BIT only. +*/ +#define TUNNEL_CSUM __cpu_to_be16(0x01)#define TUNNEL_ROUTING __cpu_to_be16(0x02)#define TUNNEL_KEY __cpu_to_be16(0x04)
@@ -181,5 +189,30 @@ enum {#define TUNNEL_OPTIONS_PRESENT \ (TUNNEL_GENEVE_OPT | TUNNEL_VXLAN_OPT | TUNNEL_ERSPAN_OPT | \ TUNNEL_GTP_OPT) +#endif + +enum { +IP_TUNNEL_CSUM_BIT =0U , +IP_TUNNEL_ROUTING_BIT =1U , +IP_TUNNEL_KEY_BIT =2U , +IP_TUNNEL_SEQ_BIT =3U , +IP_TUNNEL_STRICT_BIT =4U , +IP_TUNNEL_REC_BIT =5U , +IP_TUNNEL_VERSION_BIT =6U , +IP_TUNNEL_NO_KEY_BIT =7U , +IP_TUNNEL_DONT_FRAGMENT_BIT =8U , +IP_TUNNEL_OAM_BIT =9U , +IP_TUNNEL_CRIT_OPT_BIT =10U , +IP_TUNNEL_GENEVE_OPT_BIT =11U ,/* OPTIONS_PRESENT */ +IP_TUNNEL_VXLAN_OPT_BIT =12U ,/* OPTIONS_PRESENT */ +IP_TUNNEL_NOCACHE_BIT =13U , +IP_TUNNEL_ERSPAN_OPT_BIT =14U ,/* OPTIONS_PRESENT */ +IP_TUNNEL_GTP_OPT_BIT =15U ,/* OPTIONS_PRESENT */ + +IP_TUNNEL_VTI_BIT =16U , +IP_TUNNEL_SIT_ISATAP_BIT =IP_TUNNEL_VTI_BIT , + + __IP_TUNNEL_FLAG_NUM, +};#endif /* _UAPI_IF_TUNNEL_H_ */
net/bridge/br_vlan_tunnel.c +4 -1
@@ -65,12 +65,15 @@ static int __vlan_tunnel_info_add(struct net_bridge_vlan_group *vg, {struct metadata_dst *metadata =rtnl_dereference (vlan->tinfo.tunnel_dst);__be64 key =key32_to_tunnel_id (cpu_to_be32 (tun_id)); +IP_TUNNEL_DECLARE_FLAGS (flags) = { };int err;if (metadata)return -EEXIST ; - metadata =__ip_tun_set_dst (0 ,0 ,0 ,0 ,0 ,TUNNEL_KEY , +__set_bit (IP_TUNNEL_KEY_BIT , flags); + + metadata =__ip_tun_set_dst (0 ,0 ,0 ,0 ,0 , flags, key,0 );if (!metadata)return -EINVAL ;
net/core/filter.c +12 -8
@@ -4593,7 +4593,7 @@ BPF_CALL_4(bpf_skb_get_tunnel_key, struct sk_buff *, skb, struct bpf_tunnel_key to->tunnel_tos = info->key.tos; to->tunnel_ttl = info->key.ttl;if (flags &BPF_F_TUNINFO_FLAGS ) - to->tunnel_flags = info->key.tun_flags; + to->tunnel_flags =ip_tunnel_flags_to_be16 (info->key.tun_flags);else to->tunnel_ext =0 ;
@@ -4636,7 +4636,7 @@ BPF_CALL_3(bpf_skb_get_tunnel_opt, struct sk_buff *, skb, u8 *, to, u32, size)int err;if (unlikely (!info || - !(info->key.tun_flags &TUNNEL_OPTIONS_PRESENT ))) { + !ip_tunnel_is_options_present (info->key.tun_flags))) { err = -ENOENT ; goto err_clear; }
@@ -4706,15 +4706,17 @@ BPF_CALL_4(bpf_skb_set_tunnel_key, struct sk_buff *, skb,memset (info,0 ,sizeof (*info)); info->mode =IP_TUNNEL_INFO_TX ; - info->key.tun_flags =TUNNEL_KEY |TUNNEL_CSUM |TUNNEL_NOCACHE ; +__set_bit (IP_TUNNEL_KEY_BIT , info->key.tun_flags); +__set_bit (IP_TUNNEL_CSUM_BIT , info->key.tun_flags); +__set_bit (IP_TUNNEL_NOCACHE_BIT , info->key.tun_flags);if (flags &BPF_F_DONT_FRAGMENT ) - info->key.tun_flags |=TUNNEL_DONT_FRAGMENT ; +__set_bit (IP_TUNNEL_DONT_FRAGMENT_BIT , info->key.tun_flags);if (flags &BPF_F_ZERO_CSUM_TX ) - info->key.tun_flags &= ~TUNNEL_CSUM ; +__clear_bit (IP_TUNNEL_CSUM_BIT , info->key.tun_flags);if (flags &BPF_F_SEQ_NUMBER ) - info->key.tun_flags |=TUNNEL_SEQ ; +__set_bit (IP_TUNNEL_SEQ_BIT , info->key.tun_flags);if (flags &BPF_F_NO_TUNNEL_KEY ) - info->key.tun_flags &= ~TUNNEL_KEY ; +__clear_bit (IP_TUNNEL_KEY_BIT , info->key.tun_flags); info->key.tun_id =cpu_to_be64 (from->tunnel_id); info->key.tos = from->tunnel_tos;
@@ -4752,13 +4754,15 @@ BPF_CALL_3(bpf_skb_set_tunnel_opt, struct sk_buff *, skb, {struct ip_tunnel_info *info =skb_tunnel_info (skb);const struct metadata_dst *md =this_cpu_ptr (md_dst); +IP_TUNNEL_DECLARE_FLAGS (present) = { };if (unlikely (info != &md->u.tun_info || (size & (sizeof (u32) -1 ))))return -EINVAL ;if (unlikely (size >IP_TUNNEL_OPTS_MAX ))return -ENOMEM ; -ip_tunnel_info_opts_set (info, from, size,TUNNEL_OPTIONS_PRESENT ); +ip_tunnel_set_options_present (present); +ip_tunnel_info_opts_set (info, from, size, present);return 0 ; }
net/core/flow_dissector.c +10 -2
@@ -417,10 +417,18 @@ skb_flow_dissect_tunnel_info(const struct sk_buff *skb, target_container);if (info->options_len) { +IP_TUNNEL_DECLARE_FLAGS (flags) = { }; +u32 val; + enc_opt->len = info->options_len;ip_tunnel_info_opts_get (enc_opt->data, info); - enc_opt->dst_opt_type = info->key.tun_flags & -TUNNEL_OPTIONS_PRESENT ; + +ip_tunnel_set_options_present (flags); +bitmap_and (flags, info->key.tun_flags, flags, + __IP_TUNNEL_FLAG_NUM); + + val =find_next_bit (flags, __IP_TUNNEL_FLAG_NUM,0 ); + enc_opt->dst_opt_type = val; } } }
net/ipv4/fou_bpf.c +1 -1
@@ -66,7 +66,7 @@ __bpf_kfunc int bpf_skb_set_fou_encap(struct __sk_buff *skb_ctx, info->encap.type =TUNNEL_ENCAP_NONE ; } -if (info->key.tun_flags &TUNNEL_CSUM ) +if (test_bit (IP_TUNNEL_CSUM_BIT , info->key.tun_flags)) info->encap.flags |=TUNNEL_ENCAP_FLAG_CSUM ; info->encap.sport = encap->sport;
net/ipv4/gre_demux.c +1 -1
@@ -73,7 +73,7 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,if (unlikely (greh->flags & (GRE_VERSION |GRE_ROUTING )))return -EINVAL ; - tpi->flags =gre_flags_to_tnl_flags (greh->flags); +gre_flags_to_tnl_flags (tpi->flags, greh->flags); hdr_len =gre_calc_hlen (tpi->flags);if (!pskb_may_pull (skb, nhs + hdr_len))
net/ipv4/ip_gre.c +82 -49
328 lines not on this page · raw message
net/ipv4/ip_tunnel.c +30 -21
129 lines not on this page · raw message
net/ipv4/ip_tunnel_core.c +51 -30
204 lines not on this page · raw message
net/ipv4/ip_vti.c +23 -8
@@ -51,8 +51,11 @@ static int vti_input(struct sk_buff *skb, int nexthdr, __be32 spi,const struct iphdr *iph =ip_hdr (skb);struct net *net =dev_net (skb->dev);struct ip_tunnel_net *itn =net_generic (net, vti_net_id); +IP_TUNNEL_DECLARE_FLAGS (flags) = { }; - tunnel =ip_tunnel_lookup (itn, skb->dev->ifindex,TUNNEL_NO_KEY , +__set_bit (IP_TUNNEL_NO_KEY_BIT , flags); + + tunnel =ip_tunnel_lookup (itn, skb->dev->ifindex, flags, iph->saddr, iph->daddr,0 );if (tunnel) {if (!xfrm4_policy_check (NULL ,XFRM_POLICY_IN , skb))
@@ -322,8 +325,11 @@ static int vti4_err(struct sk_buff *skb, u32 info)const struct iphdr *iph = (const struct iphdr *)skb->data;int protocol = iph->protocol;struct ip_tunnel_net *itn =net_generic (net, vti_net_id); +IP_TUNNEL_DECLARE_FLAGS (flags) = { }; + +__set_bit (IP_TUNNEL_NO_KEY_BIT , flags); - tunnel =ip_tunnel_lookup (itn, skb->dev->ifindex,TUNNEL_NO_KEY , + tunnel =ip_tunnel_lookup (itn, skb->dev->ifindex, flags, iph->daddr, iph->saddr,0 );if (!tunnel)return -1 ;
@@ -383,20 +389,28 @@ vti_tunnel_ctl(struct net_device *dev, struct ip_tunnel_parm_kern *p, int cmd)return -EINVAL ; } -if (!(p->i_flags &GRE_KEY )) +if (!ip_tunnel_flags_is_be16_compat (p->i_flags) || + !ip_tunnel_flags_is_be16_compat (p->o_flags)) +return -EOVERFLOW ; + +if (!(ip_tunnel_flags_to_be16 (p->i_flags) &GRE_KEY )) p->i_key =0 ; -if (!(p->o_flags &GRE_KEY )) +if (!(ip_tunnel_flags_to_be16 (p->o_flags) &GRE_KEY )) p->o_key =0 ; - p->i_flags =VTI_ISVTI ; +bitmap_zero (p->i_flags, __IP_TUNNEL_FLAG_NUM); +__set_bit (IP_TUNNEL_VTI_BIT , p->i_flags); err =ip_tunnel_ctl (dev, p, cmd);if (err)return err;if (cmd !=SIOCDELTUNNEL ) { - p->i_flags |=GRE_KEY ; - p->o_flags |=GRE_KEY ; +IP_TUNNEL_DECLARE_FLAGS (flags) = { }; + +ip_tunnel_flags_from_be16 (flags,GRE_KEY ); +bitmap_or (p->i_flags, p->i_flags, flags, __IP_TUNNEL_FLAG_NUM); +bitmap_or (p->o_flags, p->o_flags, flags, __IP_TUNNEL_FLAG_NUM); }return 0 ; }
@@ -539,7 +553,8 @@ static void vti_netlink_parms(struct nlattr *data[],if (!data)return ; - parms->i_flags =VTI_ISVTI ; +bitmap_zero (parms->i_flags, __IP_TUNNEL_FLAG_NUM); +__set_bit (IP_TUNNEL_VTI_BIT , parms->i_flags);if (data[IFLA_VTI_LINK ]) parms->link =nla_get_u32 (data[IFLA_VTI_LINK ]);
net/ipv4/ipip.c +15 -6
@@ -130,13 +130,16 @@ static int ipip_err(struct sk_buff *skb, u32 info)struct net *net =dev_net (skb->dev);struct ip_tunnel_net *itn =net_generic (net, ipip_net_id);const struct iphdr *iph = (const struct iphdr *)skb->data; +IP_TUNNEL_DECLARE_FLAGS (flags) = { };const int type =icmp_hdr (skb)->type;const int code =icmp_hdr (skb)->code;struct ip_tunnel *t;int err =0 ; - t =ip_tunnel_lookup (itn, skb->dev->ifindex,TUNNEL_NO_KEY , - iph->daddr, iph->saddr,0 ); +__set_bit (IP_TUNNEL_NO_KEY_BIT , flags); + + t =ip_tunnel_lookup (itn, skb->dev->ifindex, flags, iph->daddr, + iph->saddr,0 );if (!t) { err = -ENOENT ; goto out;
@@ -213,13 +216,16 @@ static int ipip_tunnel_rcv(struct sk_buff *skb, u8 ipproto) {struct net *net =dev_net (skb->dev);struct ip_tunnel_net *itn =net_generic (net, ipip_net_id); +IP_TUNNEL_DECLARE_FLAGS (flags) = { };struct metadata_dst *tun_dst =NULL ;struct ip_tunnel *tunnel;const struct iphdr *iph; +__set_bit (IP_TUNNEL_NO_KEY_BIT , flags); + iph =ip_hdr (skb); - tunnel =ip_tunnel_lookup (itn, skb->dev->ifindex,TUNNEL_NO_KEY , - iph->saddr, iph->daddr,0 ); + tunnel =ip_tunnel_lookup (itn, skb->dev->ifindex, flags, iph->saddr, + iph->daddr,0 );if (tunnel) {const struct tnl_ptk_info *tpi;
@@ -238,7 +244,9 @@ static int ipip_tunnel_rcv(struct sk_buff *skb, u8 ipproto)if (iptunnel_pull_header (skb,0 , tpi->proto, false)) goto drop;if (tunnel->collect_md) { - tun_dst =ip_tun_rx_dst (skb,0 ,0 ,0 ); +bitmap_zero (flags, __IP_TUNNEL_FLAG_NUM); + + tun_dst =ip_tun_rx_dst (skb, flags,0 ,0 );if (!tun_dst)return 0 ;ip_tunnel_md_udp_encap (skb, &tun_dst->u.tun_info);
@@ -340,7 +348,8 @@ ipip_tunnel_ctl(struct net_device *dev, struct ip_tunnel_parm_kern *p, int cmd) } p->i_key = p->o_key =0 ; - p->i_flags = p->o_flags =0 ; +bitmap_zero (p->i_flags, __IP_TUNNEL_FLAG_NUM); +bitmap_zero (p->o_flags, __IP_TUNNEL_FLAG_NUM);return ip_tunnel_ctl (dev, p, cmd); }
net/ipv4/udp_tunnel_core.c +3 -2
@@ -183,7 +183,8 @@ void udp_tunnel_sock_release(struct socket *sock)EXPORT_SYMBOL_GPL (udp_tunnel_sock_release);struct metadata_dst *udp_tun_rx_dst (struct sk_buff *skb,unsigned short family, -__be16 flags,__be64 tunnel_id,int md_size) +const unsigned long *flags, +__be64 tunnel_id,int md_size) {struct metadata_dst *tun_dst;struct ip_tunnel_info *info;
@@ -199,7 +200,7 @@ struct metadata_dst *udp_tun_rx_dst(struct sk_buff *skb, unsigned short family, info->key.tp_src =udp_hdr (skb)->source; info->key.tp_dst =udp_hdr (skb)->dest;if (udp_hdr (skb)->check) - info->key.tun_flags |=TUNNEL_CSUM ; +__set_bit (IP_TUNNEL_CSUM_BIT , info->key.tun_flags);return tun_dst; }EXPORT_SYMBOL_GPL (udp_tun_rx_dst);
net/ipv6/ip6_gre.c +50 -37
234 lines not on this page · raw message
net/ipv6/ip6_tunnel.c +7 -7
@@ -799,17 +799,15 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,const struct ipv6hdr *ipv6h =ipv6_hdr (skb);int err; -if ((!(tpi->flags &TUNNEL_CSUM ) && - (tunnel->parms.i_flags &TUNNEL_CSUM )) || - ((tpi->flags &TUNNEL_CSUM ) && - !(tunnel->parms.i_flags &TUNNEL_CSUM ))) { +if (test_bit (IP_TUNNEL_CSUM_BIT , tunnel->parms.i_flags) != +test_bit (IP_TUNNEL_CSUM_BIT , tpi->flags)) {DEV_STATS_INC (tunnel->dev, rx_crc_errors);DEV_STATS_INC (tunnel->dev, rx_errors); goto drop; } -if (tunnel->parms.i_flags &TUNNEL_SEQ ) { -if (!(tpi->flags &TUNNEL_SEQ ) || +if (test_bit (IP_TUNNEL_SEQ_BIT , tunnel->parms.i_flags)) { +if (!test_bit (IP_TUNNEL_SEQ_BIT , tpi->flags) || (tunnel->i_seqno && (s32)(ntohl (tpi->seq) - tunnel->i_seqno) <0 )) {DEV_STATS_INC (tunnel->dev, rx_fifo_errors);
@@ -932,7 +930,9 @@ static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,if (iptunnel_pull_header (skb,0 , tpi->proto, false)) goto drop;if (t->parms.collect_md) { - tun_dst =ipv6_tun_rx_dst (skb,0 ,0 ,0 ); +IP_TUNNEL_DECLARE_FLAGS (flags) = { }; + + tun_dst =ipv6_tun_rx_dst (skb, flags,0 ,0 );if (!tun_dst) goto drop; }
net/ipv6/sit.c +5 -4
@@ -207,7 +207,7 @@ static int ipip6_tunnel_create(struct net_device *dev)__dev_addr_set (dev, &t->parms.iph.saddr,4 );memcpy (dev->broadcast, &t->parms.iph.daddr,4 ); -if ((__force u16 )t->parms.i_flags &SIT_ISATAP ) +if (test_bit (IP_TUNNEL_SIT_ISATAP_BIT , t->parms.i_flags)) dev->priv_flags |=IFF_ISATAP ; dev->rtnl_link_ops = &sit_link_ops;
@@ -1209,8 +1209,8 @@ ipip6_tunnel_get6rd(struct net_device *dev, struct ip_tunnel_parm __user *data)strscpy (kp.name, p.name,sizeof (kp.name)); kp.link = p.link; - kp.i_flags = p.i_flags; - kp.o_flags = p.o_flags; +ip_tunnel_flags_from_be16 (kp.i_flags, p.i_flags); +ip_tunnel_flags_from_be16 (kp.o_flags, p.o_flags); kp.i_key = p.i_key; kp.o_key = p.o_key;memcpy (&kp.iph, &p.iph,min (sizeof (p.iph),sizeof (kp.iph)));
@@ -1715,7 +1715,8 @@ static int ipip6_fill_info(struct sk_buff *skb, const struct net_device *dev)nla_put_u8 (skb,IFLA_IPTUN_PMTUDISC , !!(parm->iph.frag_off &htons (IP_DF ))) ||nla_put_u8 (skb,IFLA_IPTUN_PROTO , parm->iph.protocol) || -nla_put_be16 (skb,IFLA_IPTUN_FLAGS , parm->i_flags) || +nla_put_be16 (skb,IFLA_IPTUN_FLAGS , +ip_tunnel_flags_to_be16 (parm->i_flags)) || nla_put_u32(skb, IFLA_IPTUN_FWMARK, tunnel->fwmark)) goto nla_put_failure;
net/netfilter/ipvs/ip_vs_core.c +5 -1
@@ -1550,6 +1550,7 @@ static int ipvs_gre_decap(struct netns_ipvs *ipvs, struct sk_buff *skb,if (!dest) goto unk;if (dest->tun_type ==IP_VS_CONN_F_TUNNEL_TYPE_GRE ) { +IP_TUNNEL_DECLARE_FLAGS (flags);__be16 type;/* Only support version 0 and C (csum) */
@@ -1560,7 +1561,10 @@ static int ipvs_gre_decap(struct netns_ipvs *ipvs, struct sk_buff *skb,if (type !=htons (ETH_P_IP )) goto unk; *proto =IPPROTO_IPIP ; -return gre_calc_hlen (gre_flags_to_tnl_flags (greh->flags)); + +gre_flags_to_tnl_flags (flags, greh->flags); + +return gre_calc_hlen (flags); } unk:
net/netfilter/ipvs/ip_vs_xmit.c +10 -10
@@ -390,10 +390,10 @@ __ip_vs_get_out_rt(struct netns_ipvs *ipvs, int skb_af, struct sk_buff *skb, skb->ip_summed == CHECKSUM_PARTIAL) mtu -=GUE_PLEN_REMCSUM +GUE_LEN_PRIV ; }else if (dest->tun_type ==IP_VS_CONN_F_TUNNEL_TYPE_GRE ) { -__be16 tflags =0 ; +IP_TUNNEL_DECLARE_FLAGS (tflags) = { };if (dest->tun_flags &IP_VS_TUNNEL_ENCAP_FLAG_CSUM ) - tflags |=TUNNEL_CSUM ; +__set_bit (IP_TUNNEL_CSUM_BIT , tflags); mtu -=gre_calc_hlen (tflags); }if (mtu <68 ) {
@@ -553,10 +553,10 @@ __ip_vs_get_out_rt_v6(struct netns_ipvs *ipvs, int skb_af, struct sk_buff *skb, skb->ip_summed == CHECKSUM_PARTIAL) mtu -=GUE_PLEN_REMCSUM +GUE_LEN_PRIV ; }else if (dest->tun_type ==IP_VS_CONN_F_TUNNEL_TYPE_GRE ) { -__be16 tflags =0 ; +IP_TUNNEL_DECLARE_FLAGS (tflags) = { };if (dest->tun_flags &IP_VS_TUNNEL_ENCAP_FLAG_CSUM ) - tflags |=TUNNEL_CSUM ; +__set_bit (IP_TUNNEL_CSUM_BIT , tflags); mtu -=gre_calc_hlen (tflags); }if (mtu <IPV6_MIN_MTU ) {
@@ -1082,11 +1082,11 @@ ipvs_gre_encap(struct net *net, struct sk_buff *skb, {__be16 proto = *next_protocol ==IPPROTO_IPIP ?htons (ETH_P_IP ) :htons (ETH_P_IPV6 ); -__be16 tflags =0 ; +IP_TUNNEL_DECLARE_FLAGS (tflags) = { };size_t hdrlen;if (cp->dest->tun_flags &IP_VS_TUNNEL_ENCAP_FLAG_CSUM ) - tflags |=TUNNEL_CSUM ; +__set_bit (IP_TUNNEL_CSUM_BIT , tflags); hdrlen =gre_calc_hlen (tflags);gre_build_header (skb, hdrlen, tflags, proto,0 ,0 );
@@ -1165,11 +1165,11 @@ ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp, max_headroom +=sizeof (struct udphdr ) + gue_hdrlen; }else if (tun_type ==IP_VS_CONN_F_TUNNEL_TYPE_GRE ) { +IP_TUNNEL_DECLARE_FLAGS (tflags) = { };size_t gre_hdrlen; -__be16 tflags =0 ;if (tun_flags &IP_VS_TUNNEL_ENCAP_FLAG_CSUM ) - tflags |=TUNNEL_CSUM ; +__set_bit (IP_TUNNEL_CSUM_BIT , tflags); gre_hdrlen =gre_calc_hlen (tflags); max_headroom += gre_hdrlen;
@@ -1309,11 +1309,11 @@ ip_vs_tunnel_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp, max_headroom +=sizeof (struct udphdr ) + gue_hdrlen; }else if (tun_type ==IP_VS_CONN_F_TUNNEL_TYPE_GRE ) { +IP_TUNNEL_DECLARE_FLAGS (tflags) = { };size_t gre_hdrlen; -__be16 tflags =0 ;if (tun_flags &IP_VS_TUNNEL_ENCAP_FLAG_CSUM ) - tflags |=TUNNEL_CSUM ; +__set_bit (IP_TUNNEL_CSUM_BIT , tflags); gre_hdrlen =gre_calc_hlen (tflags); max_headroom += gre_hdrlen;
net/netfilter/nft_tunnel.c +26 -19
135 lines not on this page · raw message
net/openvswitch/flow_netlink.c +31 -24
181 lines not on this page · raw message
net/psample/psample.c +14 -12
@@ -220,7 +220,7 @@ static int __psample_ip_tun_to_nlattr(struct sk_buff *skb,const struct ip_tunnel_key *tun_key = &tun_info->key;int tun_opts_len = tun_info->options_len; -if (tun_key->tun_flags &TUNNEL_KEY && +if (test_bit (IP_TUNNEL_KEY_BIT , tun_key->tun_flags) &&nla_put_be64 (skb,PSAMPLE_TUNNEL_KEY_ATTR_ID , tun_key->tun_id,PSAMPLE_TUNNEL_KEY_ATTR_PAD ))return -EMSGSIZE ;
@@ -256,10 +256,10 @@ static int __psample_ip_tun_to_nlattr(struct sk_buff *skb,return -EMSGSIZE ;if (nla_put_u8 (skb,PSAMPLE_TUNNEL_KEY_ATTR_TTL , tun_key->ttl))return -EMSGSIZE ; -if ((tun_key->tun_flags &TUNNEL_DONT_FRAGMENT ) && +if (test_bit (IP_TUNNEL_DONT_FRAGMENT_BIT , tun_key->tun_flags) &&nla_put_flag (skb,PSAMPLE_TUNNEL_KEY_ATTR_DONT_FRAGMENT ))return -EMSGSIZE ; -if ((tun_key->tun_flags &TUNNEL_CSUM ) && +if (test_bit (IP_TUNNEL_CSUM_BIT , tun_key->tun_flags) &&nla_put_flag (skb,PSAMPLE_TUNNEL_KEY_ATTR_CSUM ))return -EMSGSIZE ; if (tun_key->tp_src &&
@@ -268,15 +268,16 @@ static int __psample_ip_tun_to_nlattr(struct sk_buff *skb,if (tun_key->tp_dst &&nla_put_be16 (skb,PSAMPLE_TUNNEL_KEY_ATTR_TP_DST , tun_key->tp_dst))return -EMSGSIZE ; -if ((tun_key->tun_flags &TUNNEL_OAM ) && +if (test_bit (IP_TUNNEL_OAM_BIT , tun_key->tun_flags) &&nla_put_flag (skb,PSAMPLE_TUNNEL_KEY_ATTR_OAM ))return -EMSGSIZE ;if (tun_opts_len) { -if (tun_key->tun_flags &TUNNEL_GENEVE_OPT && +if (test_bit (IP_TUNNEL_GENEVE_OPT_BIT , tun_key->tun_flags) &&nla_put (skb,PSAMPLE_TUNNEL_KEY_ATTR_GENEVE_OPTS , tun_opts_len, tun_opts))return -EMSGSIZE ; -else if (tun_key->tun_flags &TUNNEL_ERSPAN_OPT && +else if (test_bit (IP_TUNNEL_ERSPAN_OPT_BIT , + tun_key->tun_flags) &&nla_put (skb,PSAMPLE_TUNNEL_KEY_ATTR_ERSPAN_OPTS , tun_opts_len, tun_opts))return -EMSGSIZE ;
@@ -313,7 +314,7 @@ static int psample_tunnel_meta_len(struct ip_tunnel_info *tun_info)int tun_opts_len = tun_info->options_len;int sum =nla_total_size (0 );/* PSAMPLE_ATTR_TUNNEL */ -if (tun_key->tun_flags &TUNNEL_KEY ) +if (test_bit (IP_TUNNEL_KEY_BIT , tun_key->tun_flags)) sum +=nla_total_size_64bit (sizeof (u64));if (tun_info->mode &IP_TUNNEL_INFO_BRIDGE )
@@ -336,20 +337,21 @@ static int psample_tunnel_meta_len(struct ip_tunnel_info *tun_info)if (tun_key->tos) sum +=nla_total_size (sizeof (u8)); sum +=nla_total_size (sizeof (u8));/* TTL */ -if (tun_key->tun_flags &TUNNEL_DONT_FRAGMENT ) +if (test_bit (IP_TUNNEL_DONT_FRAGMENT_BIT , tun_key->tun_flags)) sum +=nla_total_size (0 ); -if (tun_key->tun_flags &TUNNEL_CSUM ) +if (test_bit (IP_TUNNEL_CSUM_BIT , tun_key->tun_flags)) sum +=nla_total_size (0 );if (tun_key->tp_src) sum +=nla_total_size (sizeof (u16));if (tun_key->tp_dst) sum +=nla_total_size (sizeof (u16)); -if (tun_key->tun_flags &TUNNEL_OAM ) +if (test_bit (IP_TUNNEL_OAM_BIT , tun_key->tun_flags)) sum +=nla_total_size (0 );if (tun_opts_len) { -if (tun_key->tun_flags &TUNNEL_GENEVE_OPT ) +if (test_bit (IP_TUNNEL_GENEVE_OPT_BIT , tun_key->tun_flags)) sum +=nla_total_size (tun_opts_len); -else if (tun_key->tun_flags &TUNNEL_ERSPAN_OPT ) +else if (test_bit (IP_TUNNEL_ERSPAN_OPT_BIT , + tun_key->tun_flags)) sum +=nla_total_size (tun_opts_len); }
net/sched/act_tunnel_key.c +20 -19
@@ -219,8 +219,9 @@ tunnel_key_copy_erspan_opt(const struct nlattr *nla, void *dst, int dst_len,static int tunnel_key_copy_opts (const struct nlattr *nla,u8 *dst,int dst_len,struct netlink_ext_ack *extack) { -int err, rem, opt_len, len =nla_len (nla), opts_len =0 , type =0 ; +int err, rem, opt_len, len =nla_len (nla), opts_len =0 ;const struct nlattr *attr, *head =nla_data (nla); +u32 type =0 ; err =nla_validate_deprecated (head, len,TCA_TUNNEL_KEY_ENC_OPTS_MAX , enc_opts_policy, extack);
@@ -230,7 +231,7 @@ static int tunnel_key_copy_opts(const struct nlattr *nla, u8 *dst,nla_for_each_attr (attr, head, len, rem) {switch (nla_type (attr)) {case TCA_TUNNEL_KEY_ENC_OPTS_GENEVE : -if (type && type !=TUNNEL_GENEVE_OPT ) { +if (type && type !=IP_TUNNEL_GENEVE_OPT_BIT ) {NL_SET_ERR_MSG (extack,"Duplicate type for geneve options" );return -EINVAL ; }
@@ -247,7 +248,7 @@ static int tunnel_key_copy_opts(const struct nlattr *nla, u8 *dst, dst_len -= opt_len; dst += opt_len; } - type =TUNNEL_GENEVE_OPT ; + type =IP_TUNNEL_GENEVE_OPT_BIT ;break ;case TCA_TUNNEL_KEY_ENC_OPTS_VXLAN :if (type) {
@@ -259,7 +260,7 @@ static int tunnel_key_copy_opts(const struct nlattr *nla, u8 *dst,if (opt_len <0 )return opt_len; opts_len += opt_len; - type =TUNNEL_VXLAN_OPT ; + type =IP_TUNNEL_VXLAN_OPT_BIT ;break ;case TCA_TUNNEL_KEY_ENC_OPTS_ERSPAN :if (type) {
@@ -271,7 +272,7 @@ static int tunnel_key_copy_opts(const struct nlattr *nla, u8 *dst,if (opt_len <0 )return opt_len; opts_len += opt_len; - type =TUNNEL_ERSPAN_OPT ; + type =IP_TUNNEL_ERSPAN_OPT_BIT ;break ; } }
@@ -302,7 +303,7 @@ static int tunnel_key_opts_set(struct nlattr *nla, struct ip_tunnel_info *info,switch (nla_type (nla_data (nla))) {case TCA_TUNNEL_KEY_ENC_OPTS_GENEVE :#if IS_ENABLED (CONFIG_INET ) - info->key.tun_flags |=TUNNEL_GENEVE_OPT ; +__set_bit (IP_TUNNEL_GENEVE_OPT_BIT , info->key.tun_flags);return tunnel_key_copy_opts (nla,ip_tunnel_info_opts (info), opts_len, extack);#else
@@ -310,7 +311,7 @@ static int tunnel_key_opts_set(struct nlattr *nla, struct ip_tunnel_info *info,#endif case TCA_TUNNEL_KEY_ENC_OPTS_VXLAN :#if IS_ENABLED (CONFIG_INET ) - info->key.tun_flags |=TUNNEL_VXLAN_OPT ; +__set_bit (IP_TUNNEL_VXLAN_OPT_BIT , info->key.tun_flags);return tunnel_key_copy_opts (nla,ip_tunnel_info_opts (info), opts_len, extack);#else
@@ -318,7 +319,7 @@ static int tunnel_key_opts_set(struct nlattr *nla, struct ip_tunnel_info *info,#endif case TCA_TUNNEL_KEY_ENC_OPTS_ERSPAN :#if IS_ENABLED (CONFIG_INET ) - info->key.tun_flags |=TUNNEL_ERSPAN_OPT ; +__set_bit (IP_TUNNEL_ERSPAN_OPT_BIT , info->key.tun_flags);return tunnel_key_copy_opts (nla,ip_tunnel_info_opts (info), opts_len, extack);#else
@@ -363,6 +364,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,bool bind = act_flags &TCA_ACT_FLAGS_BIND ;struct nlattr *tb[TCA_TUNNEL_KEY_MAX +1 ];struct tcf_tunnel_key_params *params_new; +IP_TUNNEL_DECLARE_FLAGS (flags) = { };struct metadata_dst *metadata =NULL ;struct tcf_chain *goto_ch =NULL ;struct tc_tunnel_key *parm;
@@ -371,7 +373,6 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,__be16 dst_port =0 ;__be64 key_id =0 ;int opts_len =0 ; -__be16 flags =0 ;u8 tos, ttl;int ret =0 ;u32 index;
@@ -412,16 +413,16 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, key32 =nla_get_be32 (tb[TCA_TUNNEL_KEY_ENC_KEY_ID ]); key_id =key32_to_tunnel_id (key32); - flags =TUNNEL_KEY ; +__set_bit (IP_TUNNEL_KEY_BIT , flags); } - flags |=TUNNEL_CSUM ; +__set_bit (IP_TUNNEL_CSUM_BIT , flags);if (tb[TCA_TUNNEL_KEY_NO_CSUM ] &&nla_get_u8 (tb[TCA_TUNNEL_KEY_NO_CSUM ])) - flags &= ~TUNNEL_CSUM ; +__clear_bit (IP_TUNNEL_CSUM_BIT , flags);if (nla_get_flag (tb[TCA_TUNNEL_KEY_NO_FRAG ])) - flags |=TUNNEL_DONT_FRAGMENT ; +__set_bit (IP_TUNNEL_DONT_FRAGMENT_BIT , flags);if (tb[TCA_TUNNEL_KEY_ENC_DST_PORT ]) dst_port =nla_get_be16 (tb[TCA_TUNNEL_KEY_ENC_DST_PORT ]);
@@ -663,15 +664,15 @@ static int tunnel_key_opts_dump(struct sk_buff *skb,if (!start)return -EMSGSIZE ; -if (info->key.tun_flags &TUNNEL_GENEVE_OPT ) { +if (test_bit (IP_TUNNEL_GENEVE_OPT_BIT , info->key.tun_flags)) { err =tunnel_key_geneve_opts_dump (skb, info);if (err) goto err_out; - }else if (info->key.tun_flags &TUNNEL_VXLAN_OPT ) { + }else if (test_bit (IP_TUNNEL_VXLAN_OPT_BIT , info->key.tun_flags)) { err =tunnel_key_vxlan_opts_dump (skb, info);if (err) goto err_out; - }else if (info->key.tun_flags &TUNNEL_ERSPAN_OPT ) { + }else if (test_bit (IP_TUNNEL_ERSPAN_OPT_BIT , info->key.tun_flags)) { err =tunnel_key_erspan_opts_dump (skb, info);if (err) goto err_out;
@@ -741,7 +742,7 @@ static int tunnel_key_dump(struct sk_buff *skb, struct tc_action *a,struct ip_tunnel_key *key = &info->key;__be32 key_id =tunnel_id_to_key32 (key->tun_id); - if (((key->tun_flags & TUNNEL_KEY) && + if ((test_bit(IP_TUNNEL_KEY_BIT, key->tun_flags) && nla_put_be32(skb, TCA_TUNNEL_KEY_ENC_KEY_ID, key_id)) || tunnel_key_dump_addresses(skb, ¶ms->tcft_enc_metadata->u.tun_info) ||
@@ -749,8 +750,8 @@ static int tunnel_key_dump(struct sk_buff *skb, struct tc_action *a,nla_put_be16 (skb,TCA_TUNNEL_KEY_ENC_DST_PORT , key->tp_dst)) ||nla_put_u8 (skb,TCA_TUNNEL_KEY_NO_CSUM , - !(key->tun_flags &TUNNEL_CSUM )) || - ((key->tun_flags &TUNNEL_DONT_FRAGMENT ) && + !test_bit (IP_TUNNEL_CSUM_BIT , key->tun_flags)) || + (test_bit (IP_TUNNEL_DONT_FRAGMENT_BIT , key->tun_flags) &&nla_put_flag (skb,TCA_TUNNEL_KEY_NO_FRAG )) || tunnel_key_opts_dump(skb, info)) goto nla_put_failure;
net/sched/cls_flower.c +14 -13
@@ -1413,12 +1413,13 @@ static int fl_set_enc_opt(struct nlattr **tb, struct fl_flow_key *key,switch (nla_type (nla_opt_key)) {case TCA_FLOWER_KEY_ENC_OPTS_GENEVE :if (key->enc_opts.dst_opt_type && - key->enc_opts.dst_opt_type !=TUNNEL_GENEVE_OPT ) { + key->enc_opts.dst_opt_type != +IP_TUNNEL_GENEVE_OPT_BIT ) {NL_SET_ERR_MSG (extack,"Duplicate type for geneve options" );return -EINVAL ; } option_len =0 ; - key->enc_opts.dst_opt_type =TUNNEL_GENEVE_OPT ; + key->enc_opts.dst_opt_type =IP_TUNNEL_GENEVE_OPT_BIT ; option_len =fl_set_geneve_opt (nla_opt_key, key, key_depth, option_len, extack);
@@ -1429,7 +1430,7 @@ static int fl_set_enc_opt(struct nlattr **tb, struct fl_flow_key *key,/* At the same time we need to parse through the mask * in order to verify exact and mask attribute lengths. */ - mask->enc_opts.dst_opt_type =TUNNEL_GENEVE_OPT ; + mask->enc_opts.dst_opt_type =IP_TUNNEL_GENEVE_OPT_BIT ; option_len =fl_set_geneve_opt (nla_opt_msk, mask, msk_depth, option_len, extack);
@@ -1448,7 +1449,7 @@ static int fl_set_enc_opt(struct nlattr **tb, struct fl_flow_key *key,return -EINVAL ; } option_len =0 ; - key->enc_opts.dst_opt_type =TUNNEL_VXLAN_OPT ; + key->enc_opts.dst_opt_type =IP_TUNNEL_VXLAN_OPT_BIT ; option_len =fl_set_vxlan_opt (nla_opt_key, key, key_depth, option_len, extack);
@@ -1459,7 +1460,7 @@ static int fl_set_enc_opt(struct nlattr **tb, struct fl_flow_key *key,/* At the same time we need to parse through the mask * in order to verify exact and mask attribute lengths. */ - mask->enc_opts.dst_opt_type =TUNNEL_VXLAN_OPT ; + mask->enc_opts.dst_opt_type =IP_TUNNEL_VXLAN_OPT_BIT ; option_len =fl_set_vxlan_opt (nla_opt_msk, mask, msk_depth, option_len, extack);
@@ -1478,7 +1479,7 @@ static int fl_set_enc_opt(struct nlattr **tb, struct fl_flow_key *key,return -EINVAL ; } option_len =0 ; - key->enc_opts.dst_opt_type =TUNNEL_ERSPAN_OPT ; + key->enc_opts.dst_opt_type =IP_TUNNEL_ERSPAN_OPT_BIT ; option_len =fl_set_erspan_opt (nla_opt_key, key, key_depth, option_len, extack);
@@ -1489,7 +1490,7 @@ static int fl_set_enc_opt(struct nlattr **tb, struct fl_flow_key *key,/* At the same time we need to parse through the mask * in order to verify exact and mask attribute lengths. */ - mask->enc_opts.dst_opt_type =TUNNEL_ERSPAN_OPT ; + mask->enc_opts.dst_opt_type =IP_TUNNEL_ERSPAN_OPT_BIT ; option_len =fl_set_erspan_opt (nla_opt_msk, mask, msk_depth, option_len, extack);
@@ -1509,7 +1510,7 @@ static int fl_set_enc_opt(struct nlattr **tb, struct fl_flow_key *key,return -EINVAL ; } option_len =0 ; - key->enc_opts.dst_opt_type =TUNNEL_GTP_OPT ; + key->enc_opts.dst_opt_type =IP_TUNNEL_GTP_OPT_BIT ; option_len =fl_set_gtp_opt (nla_opt_key, key, key_depth, option_len, extack);
@@ -1520,7 +1521,7 @@ static int fl_set_enc_opt(struct nlattr **tb, struct fl_flow_key *key,/* At the same time we need to parse through the mask * in order to verify exact and mask attribute lengths. */ - mask->enc_opts.dst_opt_type =TUNNEL_GTP_OPT ; + mask->enc_opts.dst_opt_type =IP_TUNNEL_GTP_OPT_BIT ; option_len =fl_set_gtp_opt (nla_opt_msk, mask, msk_depth, option_len, extack);
@@ -3043,22 +3044,22 @@ static int fl_dump_key_options(struct sk_buff *skb, int enc_opt_type, goto nla_put_failure;switch (enc_opts->dst_opt_type) { -case TUNNEL_GENEVE_OPT : +case IP_TUNNEL_GENEVE_OPT_BIT : err =fl_dump_key_geneve_opt (skb, enc_opts);if (err) goto nla_put_failure;break ; -case TUNNEL_VXLAN_OPT : +case IP_TUNNEL_VXLAN_OPT_BIT : err =fl_dump_key_vxlan_opt (skb, enc_opts);if (err) goto nla_put_failure;break ; -case TUNNEL_ERSPAN_OPT : +case IP_TUNNEL_ERSPAN_OPT_BIT : err =fl_dump_key_erspan_opt (skb, enc_opts);if (err) goto nla_put_failure;break ; -case TUNNEL_GTP_OPT : +case IP_TUNNEL_GTP_OPT_BIT : err =fl_dump_key_gtp_opt (skb, enc_opts);if (err) goto nla_put_failure;
Signature · 1 line
2.31.1
Quoted 7 lines · Marcin Szycik
Add support for creating PFCP filters in switchdev mode. Add pfcp module that allows to create a PFCP-type netdev. The netdev then can be passed to tc when creating a filter to indicate that PFCP filter should be created.
To add a PFCP filter, a special netdev must be created and passed to tc command:
Quoted 6 lines
ip link add pfcp0 type pfcp
tc filter add dev eth0 ingress prio 1 flowerpfcp_opts\
1:123/ff:fffffffffffffff0skip_hwaction mirred egress redirect dev pfcp0Changes in iproute2 are required to be able to add the pfcp netdev and use
pfcp_optsin tc (patchset will be submitted later).
iproute2 patch posted to netdev [1]. A little clarification: no changes are required to create pfcp type netdev - it can be created if pfcp module is loaded. Changes in iproute2 are only needed to use the newly introduced pfcp_opts.
[1] https://lore.kernel.org/netdev/[email protected]
Quoted 72 lines
ICE COMMS package is required as it contains PFCP profiles.
Part of this patchset modifies IP_TUNNEL_*_OPTs, which were previously stored in a
__be16. All possible values have already been used, making it impossible to add new ones.Alexander Lobakin (2):
ip_tunnel: use a separate struct to store tunnel params in the kernel
ip_tunnel: convert__be16tunnel flags to bitmapsMarcin Szycik (2):
ice: refactorICE_TC_FLWR_FIELD_ENC_OPTS
ice: Add support for PFCP hardware offload in switchdevMichal Swiatkowski (1):
pfcp: always set pfcp metadataWojciech Drewek (1):
pfcp: add PFCP moduledrivers/net/Kconfig | 13 + drivers/net/Makefile | 1 + drivers/net/bareudp.c | 19 +- drivers/net/ethernet/intel/ice/ice_ddp.c | 9 + .../net/ethernet/intel/ice/ice_flex_type.h | 4 +- .../ethernet/intel/ice/ice_protocol_type.h | 12 + drivers/net/ethernet/intel/ice/ice_switch.c | 85 +++++ drivers/net/ethernet/intel/ice/ice_switch.h | 2 + drivers/net/ethernet/intel/ice/ice_tc_lib.c | 68 +++- drivers/net/ethernet/intel/ice/ice_tc_lib.h | 7 +- .../ethernet/mellanox/mlx5/core/en/tc_tun.h | 2 +- .../mellanox/mlx5/core/en/tc_tun_encap.c | 6 +- .../mellanox/mlx5/core/en/tc_tun_geneve.c | 12 +- .../mellanox/mlx5/core/en/tc_tun_gre.c | 9 +- .../mellanox/mlx5/core/en/tc_tun_vxlan.c | 9 +- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 15 +- .../ethernet/mellanox/mlxsw/spectrum_ipip.c | 62 ++-- .../ethernet/mellanox/mlxsw/spectrum_ipip.h | 2 +- .../ethernet/mellanox/mlxsw/spectrum_span.c | 10 +- .../ethernet/netronome/nfp/flower/action.c | 12 +- drivers/net/geneve.c | 46 ++- drivers/net/pfcp.c | 303 ++++++++++++++++++ drivers/net/vxlan/vxlan_core.c | 14 +- include/linux/netdevice.h | 7 +- include/net/dst_metadata.h | 10 +- include/net/flow_dissector.h | 2 +- include/net/gre.h | 59 ++-- include/net/ip6_tunnel.h | 4 +- include/net/ip_tunnels.h | 106 +++++- include/net/pfcp.h | 83 +++++ include/net/udp_tunnel.h | 4 +- include/uapi/linux/if_tunnel.h | 36 +++ include/uapi/linux/pkt_cls.h | 14 + net/bridge/br_vlan_tunnel.c | 5 +- net/core/filter.c | 20 +- net/core/flow_dissector.c | 12 +- net/ipv4/fou_bpf.c | 2 +- net/ipv4/gre_demux.c | 2 +- net/ipv4/ip_gre.c | 148 +++++---- net/ipv4/ip_tunnel.c | 92 ++++-- net/ipv4/ip_tunnel_core.c | 83 +++-- net/ipv4/ip_vti.c | 43 ++- net/ipv4/ipip.c | 33 +- net/ipv4/ipmr.c | 2 +- net/ipv4/udp_tunnel_core.c | 5 +- net/ipv6/addrconf.c | 3 +- net/ipv6/ip6_gre.c | 87 ++--- net/ipv6/ip6_tunnel.c | 14 +- net/ipv6/sit.c | 47 ++- net/netfilter/ipvs/ip_vs_core.c | 6 +- net/netfilter/ipvs/ip_vs_xmit.c | 20 +-
Quoted 9 lines
net/netfilter/nft_tunnel.c | 45 +-- net/openvswitch/flow_netlink.c | 55 ++-- net/psample/psample.c | 26 +- net/sched/act_tunnel_key.c | 39 +-- net/sched/cls_flower.c | 134 +++++++- 56 files changed, 1501 insertions(+), 469 deletions(-) create mode 100644 drivers/net/pfcp.c create mode 100644 include/net/pfcp.h
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
RE: [Intel-wired-lan] [PATCH iwl-next v2 6/6] ice: Add support for PFCP hardware offload in switchdev
In reply to Marcin SzycikQuoted 29 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Marcin Szycik
Sent: Wednesday, June 7, 2023 4:56 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Brandeburg, Jesse <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [Intel-wired-lan] [PATCH iwl-next v2 6/6] ice: Add support for PFCP hardware offload in switchdevAdd support for creating PFCP filters in switchdev mode. Add support for parsing PFCP-specific tc options: S flag and SEID.
To create a PFCP filter, a special netdev must be created and passed to tc command:
ip link add pfcp0 type pfcp
tc filter add dev eth0 ingress prio 1 flowerpfcp_opts\
1:123/ff:fffffffffffffff0skip_hwaction mirred egress redirect dev pfcp0Changes in iproute2 are required to be able to add the pfcp netdev and use
pfcp_optsin tc.ICE COMMS package is required to create a filter as it contains PFCP profiles.
Signed-off-by Marcin Szycik <[email protected]>Reviewed-by Simon Horman <[email protected]>
Quoted 10 lines
--- drivers/net/ethernet/intel/ice/ice_ddp.c | 9 ++ .../net/ethernet/intel/ice/ice_flex_type.h | 4 +- .../ethernet/intel/ice/ice_protocol_type.h | 12 +++ drivers/net/ethernet/intel/ice/ice_switch.c | 85 +++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_switch.h | 2 + drivers/net/ethernet/intel/ice/ice_tc_lib.c | 58 +++++++++++-- drivers/net/ethernet/intel/ice/ice_tc_lib.h | 5 ++ 7 files changed, 168 insertions(+), 7 deletions(-)
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
RE: [Intel-wired-lan] [PATCH iwl-next v2 5/6] ice: refactor ICE_TC_FLWR_FIELD_ENC_OPTS
In reply to Marcin SzycikQuoted 21 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Marcin Szycik
Sent: Wednesday, June 7, 2023 4:56 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Brandeburg, Jesse <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [Intel-wired-lan] [PATCH iwl-next v2 5/6] ice: refactorICE_TC_FLWR_FIELD_ENC_OPTS
FLOW_DISSECTOR_KEY_ENC_OPTScan be used for multiple headers, but currently it is treated as GTP-exclusive in ice. RenameICE_TC_FLWR_FIELD_ENC_OPTStoICE_TC_FLWR_FIELD_GTP_OPTSand check for tunnel type earlier. After this refactor, it is easier to add new headers usingFLOW_DISSECTOR_KEY_ENC_OPTS
- instead of checking tunnel type inice_tc_count_lkups()andice_tc_fill_tunnel_outer(), it needs to be checked only once, inice_parse_tunnel_attr().
Quoted 7 lines
Signed-off-by Marcin Szycik <[email protected]>Reviewed-by Simon Horman <[email protected]>--- drivers/net/ethernet/intel/ice/ice_tc_lib.c | 10 +++++----- drivers/net/ethernet/intel/ice/ice_tc_lib.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan