[ovs-dev] [PATCH] nsh: Fix packet format to match IETF NSH draft.

Ben Pfaff blp at ovn.org
Mon Nov 6 22:14:16 UTC 2017


On Mon, Nov 06, 2017 at 06:51:57PM +0800, Yang, Yi wrote:
> On Thu, Nov 02, 2017 at 04:51:52AM +0800, Ben Pfaff wrote:
> > The NSH draft added a TTL field.  This adds basic support.
> > 
> > CC: Yi Yang <yi.y.yang at intel.com>
> > CC: Jan Scheurich <jan.scheurich at ericsson.com>
> > Signed-off-by: Ben Pfaff <blp at ovn.org>
> > ---
> >  include/openvswitch/nsh.h | 11 +++++++----
> >  lib/flow.c                |  2 +-
> >  lib/odp-execute.c         | 10 +++++-----
> >  lib/packets.c             |  4 +++-
> >  4 files changed, 16 insertions(+), 11 deletions(-)
> > 
> > diff --git a/include/openvswitch/nsh.h b/include/openvswitch/nsh.h
> > index a3611d0896b2..4d83bad1af81 100644
> > --- a/include/openvswitch/nsh.h
> > +++ b/include/openvswitch/nsh.h
> > @@ -62,7 +62,7 @@ struct nsh_md2_tlv {
> >  };
> >  
> >  struct nsh_hdr {
> > -    ovs_be16 ver_flags_len;
> > +    ovs_be16 ver_flags_ttl_len;
> >      uint8_t md_type;
> >      uint8_t next_proto;
> >      ovs_16aligned_be32 path_hdr;
> > @@ -75,8 +75,10 @@ struct nsh_hdr {
> >  /* Masking NSH header fields. */
> >  #define NSH_VER_MASK       0xc000
> >  #define NSH_VER_SHIFT      14
> > -#define NSH_FLAGS_MASK     0x3fc0
> > -#define NSH_FLAGS_SHIFT    6
> > +#define NSH_FLAGS_MASK     0x3000
> > +#define NSH_FLAGS_SHIFT    12
> > +#define NSH_TTL_MASK       0x0fc0
> > +#define NSH_TTL_SHIFT      6
> >  #define NSH_LEN_MASK       0x003f
> >  #define NSH_LEN_SHIFT      0
> >  
> > @@ -113,7 +115,8 @@ struct nsh_hdr {
> >  static inline uint16_t
> >  nsh_hdr_len(const struct nsh_hdr *nsh)
> >  {
> > -    return ((ntohs(nsh->ver_flags_len) & NSH_LEN_MASK) >> NSH_LEN_SHIFT) << 2;
> > +    return ((ntohs(nsh->ver_flags_ttl_len) & NSH_LEN_MASK)
> > +            >> NSH_LEN_SHIFT) << 2;
> >  }
> >  
> >  static inline struct nsh_md1_ctx *
> > diff --git a/lib/flow.c b/lib/flow.c
> > index 4d2b7747a124..57b6c597d207 100644
> > --- a/lib/flow.c
> > +++ b/lib/flow.c
> > @@ -546,7 +546,7 @@ parse_nsh(const void **datap, size_t *sizep, struct flow_nsh *key)
> >  
> >      memset(key, 0, sizeof(struct flow_nsh));
> >  
> > -    ver_flags_len = ntohs(nsh->ver_flags_len);
> 
> Rename ver_flags_len to ver_flags_ttl_len.
> 
> Do we need to consider new ttl key in this patch?

I assumed that at the very least we needed to set the TTL to something
reasonable initially.  This patch doesn't allow OVS to match on or to
decrement the TTL, which certainly isn't ideal but still seems like a
better situation than being entirely compatible at the wire level.

I'll accept whatever you prefer, though.


More information about the dev mailing list