[ovs-dev] [PATCH v2 1/7] nsh: datapath support for network service headers

Pravin Shelar pshelar at nicira.com
Fri Mar 7 17:50:03 UTC 2014


On Tue, Feb 25, 2014 at 3:44 PM, Pritesh Kothari
<pritesh.kothari at cisco.com> wrote:
> This patch adds support for Network Service Headers (nsh) over VXLAN
> as mentioned in [1]. Here changes are made to datapath to add nsh
> headers whenever a vxlan port with destination port as 6633 (which is
> IANA allocated port for nsh over vxlan) is created.
>
> [1] http://tools.ietf.org/html/draft-quinn-sfc-nsh-02
>
> Signed-off-by: Pritesh Kothari <pritesh.kothari at cisco.com>
>
>  create mode 100644 datapath/linux/compat/include/net/nsh.h
>
> diff --git a/datapath/datapath.c b/datapath/datapath.c
> index f7c3391..b96ad1e 100644
> --- a/datapath/datapath.c
> +++ b/datapath/datapath.c
> @@ -361,6 +361,7 @@ static size_t key_attr_size(void)
>                   + nla_total_size(1)   /* OVS_TUNNEL_KEY_ATTR_TTL */
>                   + nla_total_size(0)   /* OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT */
>                   + nla_total_size(0)   /* OVS_TUNNEL_KEY_ATTR_CSUM */
> +                 + nla_total_size(4)   /* OVS_TUNNEL_KEY_ATTR_NSP */
>                 + nla_total_size(4)   /* OVS_KEY_ATTR_IN_PORT */
>                 + nla_total_size(4)   /* OVS_KEY_ATTR_SKB_MARK */
>                 + nla_total_size(12)  /* OVS_KEY_ATTR_ETHERNET */
> diff --git a/datapath/flow.h b/datapath/flow.h
> index 270a324..6a342be 100644
> --- a/datapath/flow.h
> +++ b/datapath/flow.h
> @@ -41,9 +41,13 @@ struct sk_buff;
>  #define OVS_TUNNEL_KEY_SIZE                                    \
>          (offsetof(struct ovs_key_ipv4_tunnel, ipv4_ttl) +      \
>           FIELD_SIZEOF(struct ovs_key_ipv4_tunnel, ipv4_ttl))
> +/* Used for masking nsp and nsi values in field nsp below */
> +#define NSH_M_NSP      0xFFFFFF00
> +#define NSH_M_NSI      0x000000FF
>
>  struct ovs_key_ipv4_tunnel {
>         __be64 tun_id;
> +       __be32 nsp;      /* it contains (nsp - 24 bits | nsi - 8 bits) here */
>         __be32 ipv4_src;
>         __be32 ipv4_dst;
>         __be16 tun_flags;
> @@ -53,9 +57,10 @@ struct ovs_key_ipv4_tunnel {
>
>  static inline void ovs_flow_tun_key_init(struct ovs_key_ipv4_tunnel *tun_key,
>                                          const struct iphdr *iph, __be64 tun_id,
> -                                        __be16 tun_flags)
> +                                        __be32 nsp, __be16 tun_flags)
>  {
>         tun_key->tun_id = tun_id;
> +       tun_key->nsp = nsp;
>         tun_key->ipv4_src = iph->saddr;
>         tun_key->ipv4_dst = iph->daddr;
>         tun_key->ipv4_tos = iph->tos;
> diff --git a/datapath/flow_netlink.c b/datapath/flow_netlink.c
> index 40751cb..a2bc1e9 100644
> --- a/datapath/flow_netlink.c
> +++ b/datapath/flow_netlink.c
> @@ -333,6 +333,7 @@ static int ipv4_tun_from_nlattr(const struct nlattr *attr,
>         int rem;
>         bool ttl = false;
>         __be16 tun_flags = 0;
> +       __be32 nsp = 0;
>
>         nla_for_each_nested(a, attr, rem) {
>                 int type = nla_type(a);
> @@ -344,6 +345,7 @@ static int ipv4_tun_from_nlattr(const struct nlattr *attr,
>                         [OVS_TUNNEL_KEY_ATTR_TTL] = 1,
>                         [OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT] = 0,
>                         [OVS_TUNNEL_KEY_ATTR_CSUM] = 0,
> +                       [OVS_TUNNEL_KEY_ATTR_NSP] = sizeof(u32),
>                 };
>
>                 if (type > OVS_TUNNEL_KEY_ATTR_MAX) {
> @@ -388,11 +390,16 @@ static int ipv4_tun_from_nlattr(const struct nlattr *attr,
>                 case OVS_TUNNEL_KEY_ATTR_CSUM:
>                         tun_flags |= TUNNEL_CSUM;
>                         break;
> +               case OVS_TUNNEL_KEY_ATTR_NSP:
> +                       nsp = htonl(be32_to_cpu(nla_get_be32(a)) << 8);
> +                       tun_flags |= TUNNEL_NSP;
> +                       break;
>                 default:
>                         return -EINVAL;
>                 }
>         }
>
I have not looked at entire patch but just noticed this. If you only
going to support NSP over vxlan only we should check if this packet is
for vxlan or add support of NSP for all tunneling protocols.



More information about the dev mailing list