@@ -828,11 +828,18 @@ odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal,
}
break;
}
- case OVS_ACTION_ATTR_DECAP_NSH:
- DP_PACKET_BATCH_FOR_EACH (packet, batch) {
- decap_nsh(packet);
+ case OVS_ACTION_ATTR_DECAP_NSH: {
+ size_t i, num = batch->count;
+
+ DP_PACKET_BATCH_REFILL_FOR_EACH (i, num, packet, batch) {
+ if (decap_nsh(packet)) {
+ dp_packet_batch_refill(batch, packet, i);
+ } else {
+ dp_packet_delete(packet);
+ }
}
break;
+ }
case OVS_ACTION_ATTR_OUTPUT:
case OVS_ACTION_ATTR_TUNNEL_PUSH:
@@ -419,6 +419,9 @@ encap_nsh(struct dp_packet *packet, const struct ovs_action_encap_nsh *encap)
case PT_IPV6:
next_proto = NSH_P_IPV6;
break;
+ case PT_NSH:
+ next_proto = NSH_P_NSH;
+ break;
default:
OVS_NOT_REACHED();
}
@@ -444,7 +447,7 @@ encap_nsh(struct dp_packet *packet, const struct ovs_action_encap_nsh *encap)
packet->l3_ofs = 0;
}
-void
+bool
decap_nsh(struct dp_packet *packet)
{
struct nsh_hdr *nsh = (struct nsh_hdr *) dp_packet_l3(packet); @@ -462,8 +465,12 @@ decap_nsh(struct dp_packet *packet)
case NSH_P_IPV6:
next_pt = PT_IPV6;
break;
+ case NSH_P_NSH:
+ next_pt = PT_NSH;
+ break;
default:
- OVS_NOT_REACHED();
+ /* Unknown inner packet type. Drop packet. */
+ return false;
}
length = nsh_hdr_len(nsh);
@@ -471,6 +478,7 @@ decap_nsh(struct dp_packet *packet)
packet->packet_type = htonl(next_pt);
/* Packet must be recirculated for further processing. */
}
+ return true;
}
/* Converts hex digits in 'hex' to an Ethernet packet in '*packetp'. The diff --git a/lib/packets.h b/lib/packets.h index 19571b1..ff0c4cc 100644
@@ -409,7 +409,7 @@ void pop_eth(struct dp_packet *packet);
void encap_nsh(struct dp_packet *packet,
const struct ovs_action_encap_nsh *encap_nsh); -void decap_nsh(struct dp_packet *packet);
+bool decap_nsh(struct dp_packet *packet);
#define LLC_DSAP_SNAP 0xaa
#define LLC_SSAP_SNAP 0xaa
_______________________________________________
Thanks Jan, I have folded it to next version. -----Original Message----- From: Jan Scheurich [mailto:jan.scheurich@ericsson.com] Sent: Monday, July 17, 2017 2:49 AM To: Yang, Yi Y <yi.y.yang@intel.com>; dev@openvswitch.org Subject: RE: [PATCH 5/6] Generic encap and decap support for NSH Hi Yi, The following incremental patch drops a packet in the datapath at decap_nsh() rather than aborting if the NSH next protocol field does not match any of the supported values. Normally this should not happen if the next proto field is checked in the ofproto translation, but it feels safer to gracefully handle this case. It also adds support for NSN in NSH encapsulation in in the encap_nsh and decap_nsh Action in the datapath to match the translation logic in ofproto. BR, Jan dev mailing list dev@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev