2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

NSH: Adjust NSH wire format to the latest IETF draft

This commit adjusts the NSH user space implementation in OVS to
the latest wire format defined in draft-ietf-sfc-nsh-28 (November 3
2017). The NSH_MDTYPE field was reduced from 8 to 4 bits. The FLAGS
field is reduced from 8 to 2 bits. A new 6 bit TTL header field is
added. The TTL field is set to 63 at encap(nsh).

Match and set_field support for the newly introduced TTL header field
and a corresponding dec_nsh_ttl action is not yet included and will be
implemented in a future patch.

Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
Jan Scheurich
2017-11-07 00:40:21 +01:00
committed by Ben Pfaff
parent 7edef47b48
commit 9a180f2c00
5 changed files with 205 additions and 41 deletions

View File

@@ -277,12 +277,13 @@ odp_set_nsh(struct dp_packet *packet, const struct ovs_key_nsh *key,
const struct ovs_key_nsh *mask)
{
struct nsh_hdr *nsh = dp_packet_l3(packet);
uint8_t mdtype = nsh_md_type(nsh);
if (!mask) {
nsh->ver_flags_len = htons(key->flags << NSH_FLAGS_SHIFT) |
(nsh->ver_flags_len & ~htons(NSH_FLAGS_MASK));
nsh->ver_flags_ttl_len = htons(key->flags << NSH_FLAGS_SHIFT) |
(nsh->ver_flags_ttl_len & ~htons(NSH_FLAGS_MASK));
put_16aligned_be32(&nsh->path_hdr, key->path_hdr);
switch (nsh->md_type) {
switch (mdtype) {
case NSH_M_TYPE1:
for (int i = 0; i < 4; i++) {
put_16aligned_be32(&nsh->md1.c[i], key->c[i]);
@@ -294,16 +295,16 @@ odp_set_nsh(struct dp_packet *packet, const struct ovs_key_nsh *key,
break;
}
} else {
uint8_t flags = (ntohs(nsh->ver_flags_len) & NSH_FLAGS_MASK) >>
uint8_t flags = (ntohs(nsh->ver_flags_ttl_len) & NSH_FLAGS_MASK) >>
NSH_FLAGS_SHIFT;
flags = key->flags | (flags & ~mask->flags);
nsh->ver_flags_len = htons(flags << NSH_FLAGS_SHIFT) |
(nsh->ver_flags_len & ~htons(NSH_FLAGS_MASK));
nsh->ver_flags_ttl_len = htons(flags << NSH_FLAGS_SHIFT) |
(nsh->ver_flags_ttl_len & ~htons(NSH_FLAGS_MASK));
ovs_be32 path_hdr = get_16aligned_be32(&nsh->path_hdr);
path_hdr = key->path_hdr | (path_hdr & ~mask->path_hdr);
put_16aligned_be32(&nsh->path_hdr, path_hdr);
switch (nsh->md_type) {
switch (mdtype) {
case NSH_M_TYPE1:
for (int i = 0; i < 4; i++) {
ovs_be32 p = get_16aligned_be32(&nsh->md1.c[i]);