On Fri, May 18, 2018 at 5:49 PM, Greg Rose <[email protected]> wrote: > From: William Tu <[email protected]> > > commit 1a66a836da630cd70f3639208da549b549ce576b > Author: William Tu <[email protected]> > Date: Fri Aug 25 09:21:28 2017 -0700 > > gre: add collect_md mode to ERSPAN tunnel > > Similar to gre, vxlan, geneve, ipip tunnels, allow ERSPAN tunnels to > operate in 'collect metadata' mode. bpf_skb_[gs]et_tunnel_key() helpers > can make use of it right away. OVS can use it as well in the future. > > Signed-off-by: William Tu <[email protected]> > Signed-off-by: David S. Miller <[email protected]> > > With some adjustments for compatibility layer. > > Cc: William Tu <[email protected]> > Signed-off-by: Greg Rose <[email protected]> > ---
Looks good to me Acked-by: William Tu <[email protected]> > datapath/linux/compat/include/net/ip_tunnels.h | 68 > +++++++++++++++----------- > datapath/linux/compat/ip_gre.c | 23 ++++++--- > 2 files changed, 54 insertions(+), 37 deletions(-) > > diff --git a/datapath/linux/compat/include/net/ip_tunnels.h > b/datapath/linux/compat/include/net/ip_tunnels.h > index 2685de7..ea3fb8d 100644 > --- a/datapath/linux/compat/include/net/ip_tunnels.h > +++ b/datapath/linux/compat/include/net/ip_tunnels.h > @@ -74,14 +74,25 @@ void rpl_ip_tunnel_xmit(struct sk_buff *skb, struct > net_device *dev, > <snip> > diff --git a/datapath/linux/compat/ip_gre.c b/datapath/linux/compat/ip_gre.c > index e30e428..a5ec59c 100644 > --- a/datapath/linux/compat/ip_gre.c > +++ b/datapath/linux/compat/ip_gre.c > @@ -93,6 +93,9 @@ static __be32 tunnel_id_to_key(__be64 x) > #endif > } > > +static void erspan_build_header(struct sk_buff *skb, > + __be32 id, u32 index, bool truncate); > + > /* Called with rcu_read_lock and BH disabled. */ > static int gre_err(struct sk_buff *skb, u32 info, > const struct tnl_ptk_info *tpi) > @@ -187,7 +190,7 @@ static int erspan_rcv(struct sk_buff *skb, struct > tnl_ptk_info *tpi, > int gre_hdr_len) > { > struct net *net = dev_net(skb->dev); > - struct metadata_dst *tun_dst = NULL; > + struct metadata_dst tun_dst; > struct ip_tunnel_net *itn; > struct ip_tunnel *tunnel; > struct erspanhdr *ershdr; > @@ -823,18 +826,17 @@ static int erspan_validate(struct nlattr *tb[], struct > nlattr *data[]) > return ret; > > /* ERSPAN should only have GRE sequence and key flag */ > - flags |= nla_get_be16(data[IFLA_GRE_OFLAGS]); > - flags |= nla_get_be16(data[IFLA_GRE_IFLAGS]); > - if (flags != (GRE_SEQ | GRE_KEY)) > + if (data[IFLA_GRE_OFLAGS]) > + flags |= nla_get_be16(data[IFLA_GRE_OFLAGS]); > + if (data[IFLA_GRE_IFLAGS]) > + flags |= nla_get_be16(data[IFLA_GRE_IFLAGS]); > + if (!data[IFLA_GRE_COLLECT_METADATA] && > + flags != (GRE_SEQ | GRE_KEY)) > return -EINVAL; > > /* ERSPAN Session ID only has 10-bit. Since we reuse > * 32-bit key field as ID, check it's range. > */ > - if (data[IFLA_GRE_IKEY] && > - (ntohl(nla_get_be32(data[IFLA_GRE_IKEY])) & ~ID_MASK)) > - return -EINVAL; > - nit: I think this gets removed and later patch adds back. > if (data[IFLA_GRE_OKEY] && > (ntohl(nla_get_be32(data[IFLA_GRE_OKEY])) & ~ID_MASK)) > return -EINVAL; > @@ -983,6 +985,11 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb, > struct ip_tunnel *tunnel = netdev_priv(dev); > bool truncate = false; > > + if (tunnel->collect_md) { > + erspan_fb_xmit(skb, dev, skb->protocol); > + return NETDEV_TX_OK; > + } > + > if (gre_handle_offloads(skb, false)) > goto free_skb; > > -- > 1.8.3.1 > _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
