Add PFCP filter support
Subsystems (19)
v4 cover 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:12ab/ff:fffffffffffffff0 skip_hw action mirred egress redirect \
dev pfcp0Changes in iproute2 [1] are required to use pfcp_opts in tc.
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.
[1] https://lore.kernel.org/netdev/[email protected]
---
This patchset should be applied on top of the "boys" tree [2], as it depends on recent bitmap changes.
[2] https://github.com/norov/linux/commits/boys
---
v3: https://lore.kernel.org/intel-wired-lan/[email protected]
v2: https://lore.kernel.org/intel-wired-lan/[email protected]
v1: https://lore.kernel.org/intel-wired-lan/[email protected]
---
Alexander Lobakin (3):
ip_tunnel: use a separate struct to store tunnel params in the kernel
ip_tunnel: convert __be16 tunnel flags to bitmaps lib/bitmap: add tests for IP tunnel flags conversion helpers
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 | 8 +- .../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 | 8 +- .../mellanox/mlx5/core/en/tc_tun_vxlan.c | 9 +- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 16 +- .../ethernet/mellanox/mlxsw/spectrum_ipip.c | 56 ++-- .../ethernet/mellanox/mlxsw/spectrum_ipip.h | 2 +- .../ethernet/mellanox/mlxsw/spectrum_span.c | 10 +- .../ethernet/netronome/nfp/flower/action.c | 27 +- drivers/net/geneve.c | 44 ++- drivers/net/pfcp.c | 302 ++++++++++++++++++ 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 | 70 ++-- include/net/ip6_tunnel.h | 4 +- include/net/ip_tunnels.h | 139 ++++++-- include/net/pfcp.h | 90 ++++++ include/net/udp_tunnel.h | 4 +- include/uapi/linux/if_tunnel.h | 36 +++ include/uapi/linux/pkt_cls.h | 14 + lib/test_bitmap.c | 100 ++++++ net/bridge/br_vlan_tunnel.c | 9 +- net/core/filter.c | 26 +- net/core/flow_dissector.c | 20 +- net/ipv4/fou_bpf.c | 2 +- net/ipv4/gre_demux.c | 2 +- net/ipv4/ip_gre.c | 144 +++++---- net/ipv4/ip_tunnel.c | 109 +++++-- net/ipv4/ip_tunnel_core.c | 82 +++-- net/ipv4/ip_vti.c | 41 ++- 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 | 85 ++--- net/ipv6/ip6_tunnel.c | 14 +- net/ipv6/sit.c | 38 ++- net/netfilter/ipvs/ip_vs_core.c | 6 +- net/netfilter/ipvs/ip_vs_xmit.c | 20 +- net/netfilter/nft_tunnel.c | 44 +-- net/openvswitch/flow_netlink.c | 61 ++-- net/psample/psample.c | 26 +- net/sched/act_tunnel_key.c | 36 +-- net/sched/cls_flower.c | 134 +++++++- 57 files changed, 1652 insertions(+), 495 deletions(-) create mode 100644 drivers/net/pfcp.c create mode 100644 include/net/pfcp.h
Signature · 1 line
2.41.0
PATCH v4 1/7 ip_tunnel: use a separate struct to store tunnel params in the kernel
From: 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. Define the pieces, where the copy user <-> kernel happens, as standalone functions, and copy the data there field-by-field, so that the kernel-side structure could be easily modified later on and the users wouldn't have to care about this.
--- .../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 | 25 ++++++-- net/ipv4/ip_gre.c | 17 ++--- net/ipv4/ip_tunnel.c | 63 +++++++++++++++---- 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 | 33 +++++----- 13 files changed, 137 insertions(+), 75 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 ethtool_ops;struct kernel_hwtstamp_config ;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 ;
@@ -1408,7 +1408,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);
@@ -1661,7 +1661,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 +20 -5
@@ -110,6 +110,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;
@@ -136,7 +147,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) */
@@ -290,7 +301,11 @@ 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); +bool ip_tunnel_parm_from_user (struct ip_tunnel_parm_kern *kp, +const void __user *data); +bool ip_tunnel_parm_to_user (void __user *data,struct ip_tunnel_parm_kern *kp);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);
@@ -306,16 +321,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
@@ -782,7 +782,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;
@@ -1126,7 +1127,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);
@@ -1193,7 +1194,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);
@@ -1352,7 +1353,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;
@@ -1370,7 +1371,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;
@@ -1389,8 +1390,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);
@@ -1418,8 +1419,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);
@@ -1491,7 +1492,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 +50 -13
136 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>
@@ -2869,7 +2870,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 +18 -15
@@ -132,8 +132,8 @@ static struct ip_tunnel *ipip6_tunnel_lookup(struct net *net,return NULL ; } -static struct ip_tunnel __rcu **__ipip6_bucket (struct sit_net *sitn, -struct ip_tunnel_parm *parms) +static struct ip_tunnel __rcu ** +__ipip6_bucket (struct sit_net *sitn,struct ip_tunnel_parm_kern *parms) {__be32 remote = parms->iph.daddr;__be32 local = parms->iph.saddr;
@@ -226,7 +226,8 @@ static int ipip6_tunnel_create(struct net_device *dev) }static struct ip_tunnel *ipip6_tunnel_locate (struct net *net, -struct ip_tunnel_parm *parms,int create) +struct ip_tunnel_parm_kern *parms, +int create) {__be32 remote = parms->iph.daddr;__be32 local = parms->iph.saddr;
@@ -1135,7 +1136,8 @@ static void ipip6_tunnel_bind_dev(struct net_device *dev) dev->needed_headroom = t_hlen + hlen; } -static void ipip6_tunnel_update (struct ip_tunnel *t,struct ip_tunnel_parm *p, +static void ipip6_tunnel_update (struct ip_tunnel *t, +struct ip_tunnel_parm_kern *p,__u32 fwmark) {struct net *net = t->net;
@@ -1196,11 +1198,11 @@ static int ipip6_tunnel_get6rd(struct net_device *dev, struct ip_tunnel_parm __user *data) { struct ip_tunnel *t = netdev_priv(dev); +struct ip_tunnel_parm_kern p;struct ip_tunnel_6rd ip6rd; -struct ip_tunnel_parm p;if (dev ==dev_to_sit_net (dev)->fb_tunnel_dev) { -if (copy_from_user (&p, data,sizeof (p))) +if (!ip_tunnel_parm_from_user (&p, data))return -EFAULT ; t =ipip6_tunnel_locate (t->net, &p,0 ); }
@@ -1251,7 +1253,7 @@ static bool ipip6_valid_ip_proto(u8 ipproto) }static int -__ipip6_tunnel_ioctl_validate (struct net *net,struct ip_tunnel_parm *p) +__ipip6_tunnel_ioctl_validate (struct net *net,struct ip_tunnel_parm_kern *p) {if (!ns_capable (net->user_ns,CAP_NET_ADMIN ))return -EPERM ;
@@ -1268,7 +1270,7 @@ __ipip6_tunnel_ioctl_validate(struct net *net, struct ip_tunnel_parm *p) }static int -ipip6_tunnel_get (struct net_device *dev,struct ip_tunnel_parm *p) +ipip6_tunnel_get (struct net_device *dev,struct ip_tunnel_parm_kern *p) {struct ip_tunnel *t =netdev_priv (dev);
@@ -1281,7 +1283,7 @@ ipip6_tunnel_get(struct net_device *dev, struct ip_tunnel_parm *p) }static int -ipip6_tunnel_add (struct net_device *dev,struct ip_tunnel_parm *p) +ipip6_tunnel_add (struct net_device *dev,struct ip_tunnel_parm_kern *p) {struct ip_tunnel *t =netdev_priv (dev);int err;
@@ -1297,7 +1299,7 @@ ipip6_tunnel_add(struct net_device *dev, struct ip_tunnel_parm *p) }static int -ipip6_tunnel_change (struct net_device *dev,struct ip_tunnel_parm *p) +ipip6_tunnel_change (struct net_device *dev,struct ip_tunnel_parm_kern *p) {struct ip_tunnel *t =netdev_priv (dev);int err;
@@ -1328,7 +1330,7 @@ ipip6_tunnel_change(struct net_device *dev, struct ip_tunnel_parm *p) }static int -ipip6_tunnel_del (struct net_device *dev,struct ip_tunnel_parm *p) +ipip6_tunnel_del (struct net_device *dev,struct ip_tunnel_parm_kern *p) {struct ip_tunnel *t =netdev_priv (dev);
@@ -1348,7 +1350,8 @@ ipip6_tunnel_del(struct net_device *dev, struct ip_tunnel_parm *p) }static int -ipip6_tunnel_ctl (struct net_device *dev,struct ip_tunnel_parm *p,int cmd) +ipip6_tunnel_ctl (struct net_device *dev,struct ip_tunnel_parm_kern *p, +int cmd) {switch (cmd) {case SIOCGETTUNNEL :
@@ -1494,7 +1497,7 @@ static int ipip6_validate(struct nlattr *tb[], struct nlattr *data[], }static void ipip6_netlink_parms (struct nlattr *data[], -struct ip_tunnel_parm *parms, +struct ip_tunnel_parm_kern *parms,__u32 *fwmark) {memset (parms,0 ,sizeof (*parms));
@@ -1603,8 +1606,8 @@ static int ipip6_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;struct net *net = t->net;struct sit_net *sitn =net_generic (net, sit_net_id);#ifdef CONFIG_IPV6_SIT_6RD
@@ -1691,7 +1694,7 @@ static size_t ipip6_get_size(const struct net_device *dev)static int ipip6_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) ||
Signature · 1 line
2.41.0
PATCH v4 2/7 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_BIT and VTI_ISVTI_BIT, as they were defined not as __cpu_to_be16(), but as (__force __be16), i.e. had different positions on LE and BE. Now they both have strongly defined places. 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_* occurrences to their 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 many 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.
Most noticeable bloat-o-meter difference (.text):
vmlinux: 307/-1 (306)
gre.ko: 62/0 (62)
ip_gre.ko: 941/-217 (724) [*]
ip_tunnel.ko: 390/-900 (-510) [**]
ip_vti.ko: 138/0 (138)
ip6_gre.ko: 534/-18 (516) [*]
ip6_tunnel.ko: 118/-10 (108)
[*] gre_flags_to_tnl_flags() grew, but still is inlined [**] ip_tunnel_find() got uninlined, hence such decrease
The average code size increase in non-extreme case is 100-200 bytes per module, mostly due to sizeof(long) > sizeof(__be16), as %__IP_TUNNEL_FLAG_NUM is less than %BITS_PER_LONG and the compilers are able to expand the majority of bitmap_*() calls here into direct operations on scalars.
--- 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 | 8 +- .../mellanox/mlx5/core/en/tc_tun_vxlan.c | 9 +- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 16 ++- .../ethernet/mellanox/mlxsw/spectrum_ipip.c | 26 ++-- .../ethernet/mellanox/mlxsw/spectrum_span.c | 6 +- .../ethernet/netronome/nfp/flower/action.c | 27 +++- drivers/net/geneve.c | 44 +++--- drivers/net/vxlan/vxlan_core.c | 14 +- include/net/dst_metadata.h | 10 +- include/net/flow_dissector.h | 2 +- include/net/gre.h | 70 +++++----- include/net/ip6_tunnel.h | 4 +- include/net/ip_tunnels.h | 119 +++++++++++++--- include/net/udp_tunnel.h | 4 +- include/uapi/linux/if_tunnel.h | 33 +++++ net/bridge/br_vlan_tunnel.c | 9 +- net/core/filter.c | 26 ++-- net/core/flow_dissector.c | 20 ++- net/ipv4/fou_bpf.c | 2 +- net/ipv4/gre_demux.c | 2 +- net/ipv4/ip_gre.c | 127 +++++++++++------- net/ipv4/ip_tunnel.c | 54 ++++---- net/ipv4/ip_tunnel_core.c | 80 ++++++----- net/ipv4/ip_vti.c | 29 ++-- net/ipv4/ipip.c | 21 ++- net/ipv4/udp_tunnel_core.c | 5 +- net/ipv6/ip6_gre.c | 85 +++++++----- net/ipv6/ip6_tunnel.c | 14 +- net/ipv6/sit.c | 5 +- net/netfilter/ipvs/ip_vs_core.c | 6 +- net/netfilter/ipvs/ip_vs_xmit.c | 20 +-- net/netfilter/nft_tunnel.c | 44 +++--- net/openvswitch/flow_netlink.c | 61 +++++---- net/psample/psample.c | 26 ++-- net/sched/act_tunnel_key.c | 36 ++--- net/sched/cls_flower.c | 27 ++-- 40 files changed, 715 insertions(+), 415 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;
@@ -322,7 +326,8 @@ static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev, 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 ;
@@ -344,7 +349,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:
@@ -356,10 +362,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;
@@ -408,7 +414,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
@@ -587,7 +587,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;
@@ -596,8 +596,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 +6 -2
@@ -31,12 +31,16 @@ 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 (ip_tunnel_flags_intersect (tun_key->tun_flags, unsupp))return -EOPNOTSUPP ; greh->protocol =htons (ETH_P_TEB );
@@ -44,7 +48,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 +12 -4
@@ -5444,6 +5444,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;
@@ -5451,6 +5452,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 ;
@@ -5483,14 +5486,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 ;
@@ -5508,11 +5511,16 @@ 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) { +ip_tunnel_flags_zero (flags); +if (enc_opts.key.dst_opt_type) +__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 +16 -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,15 @@ 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) = { }; -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 ip_tunnel_flags_subset (tunnel->parms.i_flags, okflags) && +ip_tunnel_flags_subset (tunnel->parms.o_flags, okflags) && inherit_ttl && inherit_tos &&mlxsw_sp_ipip_tunnel_complete (MLXSW_SP_L3_PROTO_IPV4 , ol_dev); }
@@ -443,10 +446,13 @@ 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) = { }; + +/* 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 ip_tunnel_flags_subset (tparm.i_flags, okflags) && +ip_tunnel_flags_subset (tparm.o_flags, okflags) && 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 || + !ip_tunnel_flags_empty(tparm.i_flags) || + !ip_tunnel_flags_empty(tparm.o_flags) || /* 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 || + !ip_tunnel_flags_empty(tparm.i_flags) || + !ip_tunnel_flags_empty(tparm.o_flags) || /* 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 +21 -6
@@ -396,6 +396,17 @@ nfp_fl_push_geneve_options(struct nfp_fl_payload *nfp_fl, int *list_len,return 0 ; } +#define NFP_FL_CHECK (flag) ({ \ + IP_TUNNEL_DECLARE_FLAGS(__check) = { }; \ + __be16 __res; \ + \ + __set_bit(IP_TUNNEL_##flag##_BIT, __check); \ + __res = ip_tunnel_flags_to_be16(__check); \ + \ + BUILD_BUG_ON(__builtin_constant_p(__res) && \ + NFP_FL_TUNNEL_##flag != __res); \ +}) + static int nfp_fl_set_tun(struct nfp_app *app, struct nfp_fl_set_tun *set_tun, const struct flow_action_entry *act,
@@ -410,6 +421,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 +429,10 @@ 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 ); +NFP_FL_CHECK (CSUM ); +NFP_FL_CHECK (KEY ); +NFP_FL_CHECK (GENEVE_OPT ); +if (ip_tun->options_len && (tun_type !=NFP_FL_TUNNEL_GENEVE || !(priv->flower_ext_feats &NFP_FL_FEATS_GENEVE_OPT ))) {
@@ -427,7 +440,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 +457,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 +501,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 +27 -17
130 lines not on this page · raw message
drivers/net/vxlan/vxlan_core.c +9 -5
@@ -1584,7 +1584,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)
@@ -1716,9 +1717,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)
@@ -2403,14 +2406,14 @@ 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); } ttl = info->key.ttl; tos = info->key.tos; - 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);
@@ -2451,7 +2454,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; +ip_tunnel_flags_copy (info->key.tun_flags, flags); 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 +34 -36
119 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 +100 -19
194 lines not on this page · raw message
include/net/udp_tunnel.h +2 -2
@@ -179,8 +179,8 @@ struct dst_entry *udp_tunnel6_dst_lookup(struct sk_buff *skb, struct dst_cache *dst_cache);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 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 , +IP_TUNNEL_KEY_BIT , +IP_TUNNEL_SEQ_BIT , +IP_TUNNEL_STRICT_BIT , +IP_TUNNEL_REC_BIT , +IP_TUNNEL_VERSION_BIT , +IP_TUNNEL_NO_KEY_BIT , +IP_TUNNEL_DONT_FRAGMENT_BIT , +IP_TUNNEL_OAM_BIT , +IP_TUNNEL_CRIT_OPT_BIT , +IP_TUNNEL_GENEVE_OPT_BIT ,/* OPTIONS_PRESENT */ +IP_TUNNEL_VXLAN_OPT_BIT ,/* OPTIONS_PRESENT */ +IP_TUNNEL_NOCACHE_BIT , +IP_TUNNEL_ERSPAN_OPT_BIT ,/* OPTIONS_PRESENT */ +IP_TUNNEL_GTP_OPT_BIT ,/* OPTIONS_PRESENT */ + +IP_TUNNEL_VTI_BIT , +IP_TUNNEL_SIT_ISATAP_BIT =IP_TUNNEL_VTI_BIT , + + __IP_TUNNEL_FLAG_NUM, +};#endif /* _UAPI_IF_TUNNEL_H_ */
net/bridge/br_vlan_tunnel.c +6 -3
@@ -65,13 +65,14 @@ 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 , - key,0 ); +__set_bit (IP_TUNNEL_KEY_BIT , flags); + metadata =__ip_tun_set_dst (0 ,0 ,0 ,0 ,0 , flags, key,0 );if (!metadata)return -EINVAL ;
@@ -185,6 +186,7 @@ void br_handle_ingress_vlan_tunnel(struct sk_buff *skb,int br_handle_egress_vlan_tunnel (struct sk_buff *skb,struct net_bridge_vlan *vlan) { +IP_TUNNEL_DECLARE_FLAGS (flags) = { };struct metadata_dst *tunnel_dst;__be64 tunnel_id;int err;
@@ -202,7 +204,8 @@ int br_handle_egress_vlan_tunnel(struct sk_buff *skb,return err;if (BR_INPUT_SKB_CB (skb)->backup_nhid) { - tunnel_dst =__ip_tun_set_dst (0 ,0 ,0 ,0 ,0 ,TUNNEL_KEY , +__set_bit (IP_TUNNEL_KEY_BIT , flags); + tunnel_dst =__ip_tun_set_dst (0 ,0 ,0 ,0 ,0 , flags, tunnel_id,0 );if (!tunnel_dst)return -ENOMEM ;
net/core/filter.c +14 -12
@@ -4609,7 +4609,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 ;
@@ -4652,7 +4652,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; }
@@ -4722,15 +4722,15 @@ 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 ; -if (flags &BPF_F_DONT_FRAGMENT ) - info->key.tun_flags |=TUNNEL_DONT_FRAGMENT ; -if (flags &BPF_F_ZERO_CSUM_TX ) - info->key.tun_flags &= ~TUNNEL_CSUM ; -if (flags &BPF_F_SEQ_NUMBER ) - info->key.tun_flags |=TUNNEL_SEQ ; -if (flags &BPF_F_NO_TUNNEL_KEY ) - info->key.tun_flags &= ~TUNNEL_KEY ; +__set_bit (IP_TUNNEL_NOCACHE_BIT , info->key.tun_flags); +__assign_bit (IP_TUNNEL_DONT_FRAGMENT_BIT , info->key.tun_flags, + flags &BPF_F_DONT_FRAGMENT ); +__assign_bit (IP_TUNNEL_CSUM_BIT , info->key.tun_flags, + !(flags &BPF_F_ZERO_CSUM_TX )); +__assign_bit (IP_TUNNEL_SEQ_BIT , info->key.tun_flags, + flags &BPF_F_SEQ_NUMBER ); +__assign_bit (IP_TUNNEL_KEY_BIT , info->key.tun_flags, + !(flags &BPF_F_NO_TUNNEL_KEY )); info->key.tun_id =cpu_to_be64 (from->tunnel_id); info->key.tos = from->tunnel_tos;
@@ -4768,13 +4768,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 +14 -6
@@ -455,17 +455,25 @@ skb_flow_dissect_tunnel_info(const struct sk_buff *skb,if (dissector_uses_key (flow_dissector,FLOW_DISSECTOR_KEY_ENC_OPTS )) {struct flow_dissector_key_enc_opts *enc_opt; +IP_TUNNEL_DECLARE_FLAGS (flags) = { }; +u32 val; enc_opt =skb_flow_dissector_target (flow_dissector,FLOW_DISSECTOR_KEY_ENC_OPTS , target_container); -if (info->options_len) { - 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 ; - } +if (!info->options_len) +return ; + + enc_opt->len = info->options_len; +ip_tunnel_info_opts_get (enc_opt->data, info); + +ip_tunnel_set_options_present (flags); +ip_tunnel_flags_and (flags, info->key.tun_flags, flags); + + val =find_next_bit (flags, __IP_TUNNEL_FLAG_NUM, +IP_TUNNEL_GENEVE_OPT_BIT ); + enc_opt->dst_opt_type = val < __IP_TUNNEL_FLAG_NUM ? val :0 ; } }EXPORT_SYMBOL (skb_flow_dissect_tunnel_info);
net/ipv4/fou_bpf.c +1 -1
@@ -64,7 +64,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 +78 -49
324 lines not on this page · raw message
net/ipv4/ip_tunnel.c +29 -25
128 lines not on this page · raw message
net/ipv4/ip_tunnel_core.c +50 -30
203 lines not on this page · raw message
net/ipv4/ip_vti.c +21 -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 ;
@@ -375,6 +381,7 @@ static int vti4_err(struct sk_buff *skb, u32 info)static int vti_tunnel_ctl (struct net_device *dev,struct ip_tunnel_parm_kern *p,int cmd) { +IP_TUNNEL_DECLARE_FLAGS (flags) = { };int err =0 ;if (cmd ==SIOCADDTUNNEL || cmd ==SIOCCHGTUNNEL ) {
@@ -383,20 +390,26 @@ 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 ; +__set_bit (IP_TUNNEL_VTI_BIT , flags); +ip_tunnel_flags_copy (p->i_flags, 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_flags_from_be16 (flags,GRE_KEY ); +ip_tunnel_flags_or (p->i_flags, p->i_flags, flags); +ip_tunnel_flags_or (p->o_flags, p->o_flags, flags); }return 0 ; }
@@ -539,7 +552,7 @@ static void vti_netlink_parms(struct nlattr *data[],if (!data)return ; - parms->i_flags =VTI_ISVTI ; +__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 ); +ip_tunnel_flags_zero (flags); + + 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 ; +ip_tunnel_flags_zero (p->i_flags); +ip_tunnel_flags_zero (p->o_flags);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 +49 -36
229 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 +3 -2
@@ -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;
@@ -1704,7 +1704,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;
@@ -1310,11 +1310,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 +25 -19
134 lines not on this page · raw message
net/openvswitch/flow_netlink.c +37 -24
193 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 +18 -18
@@ -230,7 +230,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 +247,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 +259,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 +271,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 +302,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 +310,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 +318,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 +363,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 +372,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 +412,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 +663,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 +741,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 +749,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
@@ -1454,12 +1454,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);
@@ -1470,7 +1471,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);
@@ -1489,7 +1490,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);
@@ -1500,7 +1501,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);
@@ -1519,7 +1520,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);
@@ -1530,7 +1531,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);
@@ -1550,7 +1551,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);
@@ -1561,7 +1562,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);
@@ -3177,22 +3178,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.41.0
PATCH v4 3/7 lib/bitmap: add tests for IP tunnel flags conversion helpers
In reply to Marcin SzycikFrom: Alexander Lobakin <[email protected]>
Now that there are helpers for converting IP tunnel flags between the old __be16 format and the bitmap format, make sure they work as expected by adding a couple of tests to the bitmap testing suite. The helpers are all inline, so no dependencies on the related CONFIG_* (or a standalone module) are needed.
Cover three possible cases:
1. No bits past BIT(15) are set, VTI/SIT bits are not set. This conversion is almost a direct assignment.
2. No bits past BIT(15) are set, but VTI/SIT bit is set. During the conversion, it must be transformed into BIT(16) in the bitmap, but still compatible with the __be16 format.
3. The bitmap has bits past BIT(15) set (not the VTI/SIT one). The result will be truncated.
Note that currently __IP_TUNNEL_FLAG_NUM is 17 (incl. special), which means that the result of this case is currently semi-false-positive. When BIT(17) is finally here, it will be adjusted accordingly.
--- lib/test_bitmap.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+)
lib/test_bitmap.c +105 -0
@@ -14,6 +14,8 @@#include <linux/string.h> #include <linux/uaccess.h> +#include <net/ip_tunnels.h> +#include "../tools/testing/selftests/kselftest_module.h" #define EXP1_IN_BITS (sizeof(exp1) * 8)
@@ -1409,6 +1411,108 @@ static void __init test_bitmap_write_perf(void)#undef TEST_BIT_LEN +struct ip_tunnel_flags_test { +const u16 *src_bits; +const u16 *exp_bits; +u8 src_num; +u8 exp_num; +__be16 exp_val; +bool exp_comp:1 ; +}; + +#define IP_TUNNEL_FLAGS_TEST (src, comp, eval, exp) { \ + .src_bits = (src), \ + .src_num = ARRAY_SIZE(src), \ + .exp_comp = (comp), \ + .exp_val = (eval), \ + .exp_bits = (exp), \ + .exp_num = ARRAY_SIZE(exp), \ +} + +/* These are __be16-compatible and can be compared as is */ +static const u16 ip_tunnel_flags_1[]__initconst = { +IP_TUNNEL_KEY_BIT , +IP_TUNNEL_STRICT_BIT , +IP_TUNNEL_ERSPAN_OPT_BIT , +}; + +/* +* Due to the previous flags design limitation, setting either +* ``IP_TUNNEL_CSUM_BIT`` (on Big Endian) or ``IP_TUNNEL_DONT_FRAGMENT_BIT`` +* (on Little) also sets VTI/ISATAP bit. In the bitmap implementation, they +* correspond to ``BIT(16)``, which is bigger than ``U16_MAX``, but still is +* backward-compatible. +*/ +#ifdef __BIG_ENDIAN +#define IP_TUNNEL_CONFLICT_BIT IP_TUNNEL_CSUM_BIT +#else +#define IP_TUNNEL_CONFLICT_BIT IP_TUNNEL_DONT_FRAGMENT_BIT +#endif + +static const u16 ip_tunnel_flags_2_src[]__initconst = { +IP_TUNNEL_CONFLICT_BIT , +}; + +static const u16 ip_tunnel_flags_2_exp[]__initconst = { +IP_TUNNEL_CONFLICT_BIT , +IP_TUNNEL_SIT_ISATAP_BIT , +}; + +/* Bits 17 and higher are not compatible with __be16 flags */ +static const u16 ip_tunnel_flags_3_src[]__initconst = { +IP_TUNNEL_VXLAN_OPT_BIT , +17 , +18 , +20 , +}; + +static const u16 ip_tunnel_flags_3_exp[]__initconst = { +IP_TUNNEL_VXLAN_OPT_BIT , +}; + +static const struct ip_tunnel_flags_test ip_tunnel_flags_test[]__initconst = { +IP_TUNNEL_FLAGS_TEST (ip_tunnel_flags_1, true, +cpu_to_be16 (BIT (IP_TUNNEL_KEY_BIT ) | +BIT (IP_TUNNEL_STRICT_BIT ) | +BIT (IP_TUNNEL_ERSPAN_OPT_BIT )), + ip_tunnel_flags_1), +IP_TUNNEL_FLAGS_TEST (ip_tunnel_flags_2_src, true,VTI_ISVTI , + ip_tunnel_flags_2_exp), +IP_TUNNEL_FLAGS_TEST (ip_tunnel_flags_3_src, +/* +* This must be set to ``false`` once +* ``__IP_TUNNEL_FLAG_NUM`` goes above 17. +*/ + true, +cpu_to_be16 (BIT (IP_TUNNEL_VXLAN_OPT_BIT )), + ip_tunnel_flags_3_exp), +}; + +static void __init test_ip_tunnel_flags (void ) +{ +for (u32 i =0 ; i <ARRAY_SIZE (ip_tunnel_flags_test); i++) { +typeof (*ip_tunnel_flags_test) *test = &ip_tunnel_flags_test[i]; +IP_TUNNEL_DECLARE_FLAGS (src) = { }; +IP_TUNNEL_DECLARE_FLAGS (exp) = { }; +IP_TUNNEL_DECLARE_FLAGS (out); + +for (u32 j =0 ; j < test->src_num; j++) +__set_bit (test->src_bits[j], src); + +for (u32 j =0 ; j < test->exp_num; j++) +__set_bit (test->exp_bits[j], exp); + +ip_tunnel_flags_from_be16 (out, test->exp_val); + +expect_eq_uint (test->exp_comp, +ip_tunnel_flags_is_be16_compat (src)); +expect_eq_uint ((__force u16 )test->exp_val, + (__force u16 )ip_tunnel_flags_to_be16 (src)); + +__ipt_flag_op (expect_eq_bitmap, exp, out); + } +} +static void __init selftest (void ) {test_zero_clear ();
@@ -1428,6 +1532,7 @@ static void __init selftest(void)test_bitmap_read_write ();test_bitmap_read_perf ();test_bitmap_write_perf (); +test_ip_tunnel_flags ();test_find_nth_bit (); test_for_each_set_bit();
Signature · 1 line
2.41.0
PATCH v4 4/7 pfcp: add PFCP module
In reply to Marcin SzycikFrom: 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
--- drivers/net/Kconfig | 13 +++ drivers/net/Makefile | 1 + drivers/net/pfcp.c | 223 +++++++++++++++++++++++++++++++++++++++++++ include/net/pfcp.h | 17 ++++ 4 files changed, 254 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
@@ -38,6 +38,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 +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _PFCP_H_ +#define _PFCP_H_ + +#include <linux/netdevice.h> +#include <linux/string.h> +#include <linux/types.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.41.0
PATCH v4 5/7 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.
--- drivers/net/pfcp.c | 81 ++++++++++++++++++++++++- include/net/ip_tunnels.h | 3 + include/net/pfcp.h | 73 ++++++++++++++++++++++ include/uapi/linux/if_tunnel.h | 3 + include/uapi/linux/pkt_cls.h | 14 +++++ lib/test_bitmap.c | 7 +-- net/sched/cls_flower.c | 107 +++++++++++++++++++++++++++++++++ 7 files changed, 281 insertions(+), 7 deletions(-)
drivers/net/pfcp.c +80 -1
@@ -21,6 +21,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 ;
@@ -29,6 +31,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); + +ip_tunnel_flags_zero (flags); + 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);
@@ -39,6 +113,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); }
@@ -48,7 +123,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 = {
@@ -94,6 +169,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 +3 -0
@@ -216,6 +216,7 @@ static inline void ip_tunnel_set_options_present(unsigned long *flags)__set_bit (IP_TUNNEL_VXLAN_OPT_BIT , present);__set_bit (IP_TUNNEL_ERSPAN_OPT_BIT , present);__set_bit (IP_TUNNEL_GTP_OPT_BIT , present); +__set_bit (IP_TUNNEL_PFCP_OPT_BIT , present);ip_tunnel_flags_or (flags, flags, present); }
@@ -228,6 +229,7 @@ static inline void ip_tunnel_clear_options_present(unsigned long *flags)__set_bit (IP_TUNNEL_VXLAN_OPT_BIT , present);__set_bit (IP_TUNNEL_ERSPAN_OPT_BIT , present);__set_bit (IP_TUNNEL_GTP_OPT_BIT , present); +__set_bit (IP_TUNNEL_PFCP_OPT_BIT , present);__ipt_flag_op (bitmap_andnot, flags, flags, present); }
@@ -240,6 +242,7 @@ static inline bool ip_tunnel_is_options_present(const unsigned long *flags)__set_bit (IP_TUNNEL_VXLAN_OPT_BIT , present);__set_bit (IP_TUNNEL_ERSPAN_OPT_BIT , present);__set_bit (IP_TUNNEL_GTP_OPT_BIT , present); +__set_bit (IP_TUNNEL_PFCP_OPT_BIT , present);return ip_tunnel_flags_intersect (flags, present); }
include/net/pfcp.h +73 -0
85 lines not on this page · raw message
include/uapi/linux/if_tunnel.h +3 -0
@@ -212,6 +212,9 @@ enum {IP_TUNNEL_VTI_BIT ,IP_TUNNEL_SIT_ISATAP_BIT =IP_TUNNEL_VTI_BIT , +/* Flags starting from here are not available via the old UAPI */ +IP_TUNNEL_PFCP_OPT_BIT ,/* OPTIONS_PRESENT */ + __IP_TUNNEL_FLAG_NUM, };
include/uapi/linux/pkt_cls.h +14 -0
@@ -634,6 +634,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, };
@@ -683,6 +687,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 ,
lib/test_bitmap.c +1 -6
@@ -1478,12 +1478,7 @@ static const struct ip_tunnel_flags_test ip_tunnel_flags_test[] __initconst = { ip_tunnel_flags_1),IP_TUNNEL_FLAGS_TEST (ip_tunnel_flags_2_src, true,VTI_ISVTI , ip_tunnel_flags_2_exp), -IP_TUNNEL_FLAGS_TEST (ip_tunnel_flags_3_src, -/* -* This must be set to ``false`` once -* ``__IP_TUNNEL_FLAG_NUM`` goes above 17. -*/ - true, +IP_TUNNEL_FLAGS_TEST (ip_tunnel_flags_3_src, false,cpu_to_be16 (BIT (IP_TUNNEL_VXLAN_OPT_BIT )), ip_tunnel_flags_3_exp), };
net/sched/cls_flower.c +107 -0
149 lines not on this page · raw message
Signature · 1 line
2.41.0
PATCH v4 6/7 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
@@ -35,7 +35,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 |
@@ -219,8 +219,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) {
@@ -1360,7 +1359,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);
@@ -1371,7 +1371,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.41.0
PATCH v4 7/7 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:12ab/ff:fffffffffffffff0 skip_hw action mirred egress redirect \
dev pfcp0Changes in iproute2 [1] are required to be able to 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 | 6 ++ 7 files changed, 169 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;
@@ -418,6 +429,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#define ICE_SW_RULE_VSI_LIST_SIZE (s, n) struct_size((s), vsi, (n))#define ICE_SW_RULE_RX_TX_HDR_SIZE (s, l) struct_size((s), hdr_data, (l))
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 +6 -0
@@ -4,6 +4,9 @@#ifndef _ICE_TC_LIB_H_#define _ICE_TC_LIB_H_ +#include <linux/bits.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 +37,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 +165,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.41.0
Tony Nguyen
maintainerQuoted 16 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:
ip link add pfcp0 type pfcp tc filter add dev eth0 ingress prio 1 flower pfcp_opts \ 1:12ab/ff:fffffffffffffff0 skip_hw action mirred egress redirect \ dev pfcp0Changes in iproute2 [1] are required to use
pfcp_optsin tc.ICE COMMS package is required as it contains PFCP profiles.
Quoted 8 lines
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.[1] https://lore.kernel.org/netdev/[email protected]
---
This patchset should be applied on top of the "boys" tree [2], as it depends on recent bitmap changes.
Is this for comment only (RFC)? This doesn't seem to apply to iwl-next and if this based on, and has dependencies from, another tree, I can't apply them here.
Quoted 83 lines
[2] https://github.com/norov/linux/commits/boys
---
v3: https://lore.kernel.org/intel-wired-lan/[email protected]
v2: https://lore.kernel.org/intel-wired-lan/[email protected]
v1: https://lore.kernel.org/intel-wired-lan/[email protected]
---Alexander Lobakin (3):
ip_tunnel: use a separate struct to store tunnel params in the kernel
ip_tunnel: convert__be16tunnel flags to bitmaps lib/bitmap: add tests for IP tunnel flags conversion helpersMarcin 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 | 8 +- .../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 | 8 +- .../mellanox/mlx5/core/en/tc_tun_vxlan.c | 9 +- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 16 +- .../ethernet/mellanox/mlxsw/spectrum_ipip.c | 56 ++-- .../ethernet/mellanox/mlxsw/spectrum_ipip.h | 2 +- .../ethernet/mellanox/mlxsw/spectrum_span.c | 10 +- .../ethernet/netronome/nfp/flower/action.c | 27 +- drivers/net/geneve.c | 44 ++- drivers/net/pfcp.c | 302 ++++++++++++++++++ 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 | 70 ++-- include/net/ip6_tunnel.h | 4 +- include/net/ip_tunnels.h | 139 ++++++-- include/net/pfcp.h | 90 ++++++ include/net/udp_tunnel.h | 4 +- include/uapi/linux/if_tunnel.h | 36 +++ include/uapi/linux/pkt_cls.h | 14 + lib/test_bitmap.c | 100 ++++++ net/bridge/br_vlan_tunnel.c | 9 +- net/core/filter.c | 26 +- net/core/flow_dissector.c | 20 +- net/ipv4/fou_bpf.c | 2 +- net/ipv4/gre_demux.c | 2 +- net/ipv4/ip_gre.c | 144 +++++---- net/ipv4/ip_tunnel.c | 109 +++++-- net/ipv4/ip_tunnel_core.c | 82 +++-- net/ipv4/ip_vti.c | 41 ++- 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 | 85 ++--- net/ipv6/ip6_tunnel.c | 14 +- net/ipv6/sit.c | 38 ++- net/netfilter/ipvs/ip_vs_core.c | 6 +- net/netfilter/ipvs/ip_vs_xmit.c | 20 +- net/netfilter/nft_tunnel.c | 44 +-- net/openvswitch/flow_netlink.c | 61 ++-- net/psample/psample.c | 26 +- net/sched/act_tunnel_key.c | 36 +-- net/sched/cls_flower.c | 134 +++++++- 57 files changed, 1652 insertions(+), 495 deletions(-)create mode 100644
drivers/net/pfcp.c
create mode 100644include/net/pfcp.h
From: Tony Nguyen <[email protected]>
Date: Fri, 8 Dec 2023 13:34:10 -0800
Quoted 30 lines · Marcin Szycik
Quoted 21 lines
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 flowerpfcp_opts\
1:12ab/ff:fffffffffffffff0skip_hwaction mirred egress redirect \
dev pfcp0Changes in iproute2 [1] are required to use
pfcp_optsin tc.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.Quoted 5 lines
[1]
https://lore.kernel.org/netdev/[email protected]
---
This patchset should be applied on top of the "boys" tree [2], as it depends on recent bitmap changes.
Quoted 3 lines
Is this for comment only (RFC)? This doesn't seem to apply to iwl-next and if this based on, and has dependencies from, another tree, I can't apply them here.
It's not an RFC.
The series contains generic code changes and must go directly through net-next. The dependency on the bitmap tree was discussed with Jakub and Yury and we agreed that the netdev guys will pull it before applying this one.
Thanks,
Olek
Tony Nguyen
maintainerQuoted 33 lines · Alexander Lobakin
From: Tony Nguyen <[email protected]>
Date: Fri, 8 Dec 2023 13:34:10 -0800Quoted 30 lines · Marcin Szycik
Quoted 26 lines
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 flowerpfcp_opts\
1:12ab/ff:fffffffffffffff0skip_hwaction mirred egress redirect \
dev pfcp0Changes in iproute2 [1] are required to use
pfcp_optsin tc.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.[1]
https://lore.kernel.org/netdev/[email protected]
---
This patchset should be applied on top of the "boys" tree [2], as it depends on recent bitmap changes.
Quoted 7 lines
Quoted 3 lines
Is this for comment only (RFC)? This doesn't seem to apply to iwl-next and if this based on, and has dependencies from, another tree, I can't apply them here.
It's not an RFC.
The series contains generic code changes and must go directly through net-next.
Should this be marked for 'net-next' rather than 'iwl-next' then?
Thanks,
Tony
Quoted 6 lines
The dependency on the bitmap tree was discussed with Jakub and Yury and we agreed that the netdev guys will pull it before applying this one.
Thanks,
Olek
Quoted 40 lines · Tony Nguyen
Quoted 37 lines · Alexander Lobakin
From: Tony Nguyen <[email protected]>
Date: Fri, 8 Dec 2023 13:34:10 -0800Quoted 33 lines · Marcin Szycik
Quoted 21 lines
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 flowerpfcp_opts\
1:12ab/ff:fffffffffffffff0skip_hwaction mirred egress redirect \
dev pfcp0Changes in iproute2 [1] are required to use
pfcp_optsin tc.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.Quoted 5 lines
[1]
https://lore.kernel.org/netdev/[email protected]
---
This patchset should be applied on top of the "boys" tree [2], as it depends on recent bitmap changes.Is this for comment only (RFC)? This doesn't seem to apply to iwl-next and if this based on, and has dependencies from, another tree, I can't apply them here.
Quoted 5 lines
Quoted 3 lines
It's not an RFC.
The series contains generic code changes and must go directly through net-next.Should this be marked for 'net-next' rather than 'iwl-next' then?
My bad, sorry.
This series should go directly to net-next.
Thanks,
Marcin
Quoted 14 lines
Thanks,
TonyQuoted 6 lines
The dependency on the bitmap tree was discussed with Jakub and Yury and we agreed that the netdev guys will pull it before applying this one.
Thanks,
Olek_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
From: Marcin Szycik <[email protected]>
Date: Tue, 12 Dec 2023 11:45:24 +0100
Quoted 47 lines · Tony Nguyen
Quoted 44 lines · Alexander Lobakin
Quoted 40 lines
From: Tony Nguyen <[email protected]>
Date: Fri, 8 Dec 2023 13:34:10 -0800Quoted 30 lines · Marcin Szycik
Quoted 21 lines
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 flowerpfcp_opts\
1:12ab/ff:fffffffffffffff0skip_hwaction mirred egress redirect \
dev pfcp0Changes in iproute2 [1] are required to use
pfcp_optsin tc.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.Quoted 5 lines
[1]
https://lore.kernel.org/netdev/[email protected]
---
This patchset should be applied on top of the "boys" tree [2], as it depends on recent bitmap changes.Quoted 3 lines
Is this for comment only (RFC)? This doesn't seem to apply to iwl-next and if this based on, and has dependencies from, another tree, I can't apply them here.
It's not an RFC.
The series contains generic code changes and must go directly through net-next.
Quoted 15 lines
Quoted 1 line
Should this be marked for 'net-next' rather than 'iwl-next' then?
My bad, sorry.
This series should go directly to net-next.Thanks,
MarcinQuoted 7 lines
Thanks,
TonyQuoted 3 lines
The dependency on the bitmap tree was discussed with Jakub and Yury and we agreed that the netdev guys will pull it before applying this one.
Ping? :s
Or should we resubmit?
Thanks,
Olek
Jakub Kicinski
maintainerQuoted 2 lines · On Fri, 15 Dec 2023 11:11:23 +0100 Alexander Lobakin wrote:
Ping? :s
Or should we resubmit?
Can you wait for next merge window instead?
We're getting flooded with patches as everyone seemingly tries to get their own (i.e. the most important!) work merged before the end of the year. The set of PRs from the bitmap tree which Linus decided not to pull is not empty. So we'd have to go figure out what's exactly is in that branch we're supposed to pull, and whether it's fine. It probably is, but you see, this is a problem which can be solved by waiting, and letting Linus pull it himself. While the 150 patches we're getting a day now have to be looked at.
Quoted 4 lines · Jakub Kicinski
Quoted 2 lines · On Fri, 15 Dec 2023 11:11:23 +0100 Alexander Lobakin wrote:
Ping? :s
Or should we resubmit?
Quoted 9 lines
Can you wait for next merge window instead?
We're getting flooded with patches as everyone seemingly tries to get their own (i.e. the most important!) work merged before the end of the year. The set of PRs from the bitmap tree which Linus decided not to pull is not empty. So we'd have to go figure out what's exactly is in that branch we're supposed to pull, and whether it's fine. It probably is, but you see, this is a problem which can be solved by waiting, and letting Linus pull it himself. While the 150 patches we're getting a day now have to be looked at.
Let's wait to the next window then.
Thanks,
Marcin
From: Marcin Szycik <[email protected]>
Date: Mon, 18 Dec 2023 11:04:01 +0100
Quoted 17 lines · Jakub Kicinski
Quoted 13 lines · On Fri, 15 Dec 2023 11:11:23 +0100 Alexander Lobakin wrote:
Quoted 2 lines
Ping? :s
Or should we resubmit?Can you wait for next merge window instead?
We're getting flooded with patches as everyone seemingly tries to get their own (i.e. the most important!) work merged before the end of the year. The set of PRs from the bitmap tree which Linus decided not to pull is not empty. So we'd have to go figure out what's exactly is in that branch we're supposed to pull, and whether it's fine. It probably is, but you see, this is a problem which can be solved by waiting, and letting Linus pull it himself. While the 150 patches we're getting a day now have to be looked at.
Quoted 1 line
Let's wait to the next window then.
Hey Yury,
Given that PFCP will be resent in the next window...
Your "boys" tree is in fact self-contained -- those are mostly optimizations and cleanups, and for the new API -- bitmap_{read,write}() -- it has internal users (after "bitmap: make bitmap_{get,set}_value8() use bitmap_{read,write}()"). IOW, I don't see a reason for not merging it into your main for-next tree (this week :p).
What do you think?
Quoted 3 lines
Thanks,
Marcin
Thanks,
Olek
Yury Norov
maintainer+ Alexander Potapenko
Quoted 24 lines · Alexander Lobakin
From: Marcin Szycik <[email protected]>
Date: Mon, 18 Dec 2023 11:04:01 +0100Quoted 17 lines · Jakub Kicinski
Quoted 13 lines · On Fri, 15 Dec 2023 11:11:23 +0100 Alexander Lobakin wrote:
Quoted 2 lines
Ping? :s
Or should we resubmit?Can you wait for next merge window instead?
We're getting flooded with patches as everyone seemingly tries to get their own (i.e. the most important!) work merged before the end of the year. The set of PRs from the bitmap tree which Linus decided not to pull is not empty. So we'd have to go figure out what's exactly is in that branch we're supposed to pull, and whether it's fine. It probably is, but you see, this is a problem which can be solved by waiting, and letting Linus pull it himself. While the 150 patches we're getting a day now have to be looked at.Quoted 1 line
Let's wait to the next window then.
Hey Yury,
Quoted 8 lines
Given that PFCP will be resent in the next window...
Your "boys" tree is in fact self-contained -- those are mostly optimizations and cleanups, and for the new API -- bitmap_{read,write}() -- it has internal users (after "bitmap: make bitmap_{get,set}_value8() use bitmap_{read,write}()"). IOW, I don't see a reason for not merging it into your main for-next tree (this week :p).
What do you think?
I think that there's already enough mess with this patch. Alexander submitted new version of his MTE series together with the patch.
https://lore.kernel.org/lkml/ZXtciaxTKFBiui%2FX@yury-ThinkPad/T/
Now you're asking me to merge it separately. I don't want to undercut arm64 folks.
Can you guys decide what you want? If you want to move bitmap_read/write() with my branch, I need to send it in -next for testing ASAP. And for that, as I already said, I need at least one active user in current kernel tree. (Yes, bitmap_get_value8() counts.)
If you want to move it this way, please resend all the patches together.
Thanks,
Yury
Quoted 37 lines · Yury Norov
+ Alexander Potapenko
Quoted 24 lines · Alexander Lobakin
From: Marcin Szycik <[email protected]>
Date: Mon, 18 Dec 2023 11:04:01 +0100Quoted 17 lines · Jakub Kicinski
Quoted 13 lines · On Fri, 15 Dec 2023 11:11:23 +0100 Alexander Lobakin wrote:
Quoted 2 lines
Ping? :s
Or should we resubmit?Can you wait for next merge window instead?
We're getting flooded with patches as everyone seemingly tries to get their own (i.e. the most important!) work merged before the end of the year. The set of PRs from the bitmap tree which Linus decided not to pull is not empty. So we'd have to go figure out what's exactly is in that branch we're supposed to pull, and whether it's fine. It probably is, but you see, this is a problem which can be solved by waiting, and letting Linus pull it himself. While the 150 patches we're getting a day now have to be looked at.Quoted 1 line
Let's wait to the next window then.
Hey Yury,
Quoted 8 lines
Given that PFCP will be resent in the next window...
Your "boys" tree is in fact self-contained -- those are mostly optimizations and cleanups, and for the new API -- bitmap_{read,write}() -- it has internal users (after "bitmap: make bitmap_{get,set}_value8() use bitmap_{read,write}()"). IOW, I don't see a reason for not merging it into your main for-next tree (this week :p).
What do you think?
Quoted 2 lines
I think that there's already enough mess with this patch. Alexander submitted new version of his MTE series together with the patch.
Yeah, sorry about that. Because the MTE part of the patches was still awaiting review, I thought it would be better to land the bitmap API separately, but as you pointed out there should be at least one user for it, which it wouldn't have in that case.
I don't have a strong preference about whether to submit the patches before or after the end of year - in fact I don't think they are urgent enough, and we'd better postpone them till January.
So unless Alexander has urgent fixes depending on my bitmap patches, I'd suggest waiting till they are taken via the arm64 tree.
Quoted 10 lines
https://lore.kernel.org/lkml/ZXtciaxTKFBiui%2FX@yury-ThinkPad/T/
Now you're asking me to merge it separately. I don't want to undercut arm64 folks.
Can you guys decide what you want? If you want to move bitmap_read/write() with my branch, I need to send it in -next for testing ASAP. And for that, as I already said, I need at least one active user in current kernel tree. (Yes,
bitmap_get_value8()counts.)
Quoted 5 lines
If you want to move it this way, please resend all the patches together.
Thanks,
Yury
--
Alexander Potapenko
Software Engineer
Google Germany GmbH
Erika-Mann-Straße, 33
80636 München
Geschäftsführer: Paul Manicle, Liana Sebastian
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
From: Alexander Potapenko <[email protected]>
Date: Mon, 18 Dec 2023 17:16:09 +0100
Quoted 5 lines · Yury Norov
Quoted 4 lines
+ Alexander Potapenko
On Mon, Dec 18, 2023 at 01:47:01PM +0100, Alexander Lobakin wrote:
[...]
Quoted 19 lines
Quoted 11 lines
Quoted 10 lines
Hey Yury,
Given that PFCP will be resent in the next window...
Your "boys" tree is in fact self-contained -- those are mostly optimizations and cleanups, and for the new API -- bitmap_{read,write}() -- it has internal users (after "bitmap: make bitmap_{get,set}_value8() use bitmap_{read,write}()"). IOW, I don't see a reason for not merging it into your main for-next tree (this week :p).
What do you think?Quoted 2 lines
I think that there's already enough mess with this patch. Alexander submitted new version of his MTE series together with the patch.
Yeah, sorry about that. Because the MTE part of the patches was still awaiting review, I thought it would be better to land the bitmap API separately, but as you pointed out there should be at least one user for it, which it wouldn't have in that case.
Quoted 6 lines
I don't have a strong preference about whether to submit the patches before or after the end of year - in fact I don't think they are urgent enough, and we'd better postpone them till January.
So unless Alexander has urgent fixes depending on my bitmap patches, I'd suggest waiting till they are taken via the arm64 tree.
No, nothing urgent. Sounds good, no need to rush at the end of the dev cycle.
Quoted 6 lines
Quoted 6 lines
https://lore.kernel.org/lkml/ZXtciaxTKFBiui%2FX@yury-ThinkPad/T/
Now you're asking me to merge it separately. I don't want to undercut arm64 folks.
Quoted 7 lines
Quoted 7 lines
Can you guys decide what you want? If you want to move bitmap_read/write() with my branch, I need to send it in -next for testing ASAP. And for that, as I already said, I need at least one active user in current kernel tree. (Yes,
bitmap_get_value8()counts.)If you want to move it this way, please resend all the patches together.
[...]
Thanks,
Olek