Current tunnel-pop API does not allow the netdev implementation retain a packet but STT can keep a packet from batch of packets during TCP reassembly processing. To return exact count of valid packet STT need to pass this number of packet parameter as a reference.
Signed-off-by: Pravin B Shelar <pshe...@nicira.com> --- lib/dpif-netdev.c | 9 +++++++-- lib/netdev-provider.h | 2 +- lib/netdev.c | 12 +++++++++--- lib/netdev.h | 2 +- lib/tnl-push-pop.c | 9 ++++++--- lib/tnl-push-pop.h | 6 +++--- 6 files changed, 27 insertions(+), 13 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index c746cc2..215e9b6 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -3482,7 +3482,6 @@ dp_execute_cb(void *aux_, struct dp_packet **packets, int cnt, struct dp_netdev *dp = pmd->dp; int type = nl_attr_type(a); struct dp_netdev_port *p; - int i; switch ((enum ovs_action_attr)type) { case OVS_ACTION_ATTR_OUTPUT: @@ -3529,8 +3528,12 @@ dp_execute_cb(void *aux_, struct dp_packet **packets, int cnt, packets = tnl_pkt; } - err = netdev_pop_header(p->netdev, packets, cnt); + err = netdev_pop_header(p->netdev, packets, &cnt); + if (!cnt) { + return; + } if (!err) { + int i; for (i = 0; i < cnt; i++) { packets[i]->md.in_port.odp_port = portno; @@ -3553,6 +3556,7 @@ dp_execute_cb(void *aux_, struct dp_packet **packets, int cnt, struct ofpbuf actions; struct flow flow; ovs_u128 ufid; + int i; userdata = nl_attr_find_nested(a, OVS_USERSPACE_ATTR_USERDATA); ofpbuf_init(&actions, 0); @@ -3584,6 +3588,7 @@ dp_execute_cb(void *aux_, struct dp_packet **packets, int cnt, case OVS_ACTION_ATTR_RECIRC: if (*depth < MAX_RECIRC_DEPTH) { struct dp_packet *recirc_pkts[NETDEV_MAX_BURST]; + int i; if (!may_steal) { dp_netdev_clone_pkt_batch(recirc_pkts, packets, cnt); diff --git a/lib/netdev-provider.h b/lib/netdev-provider.h index fbf2e98..9a3299b 100644 --- a/lib/netdev-provider.h +++ b/lib/netdev-provider.h @@ -269,7 +269,7 @@ struct netdev_class { /* Pop tunnel header from packet, build tunnel metadata and resize packet * for further processing. */ - int (*pop_header)(struct dp_packet *packet); + int (*pop_header)(struct dp_packet **packet); /* Returns the id of the numa node the 'netdev' is on. If there is no * such info, returns NETDEV_NUMA_UNSPEC. */ diff --git a/lib/netdev.c b/lib/netdev.c index e3b70b1..e16a3be 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -747,9 +747,9 @@ netdev_send(struct netdev *netdev, int qid, struct dp_packet **buffers, } int -netdev_pop_header(struct netdev *netdev, struct dp_packet **buffers, int cnt) +netdev_pop_header(struct netdev *netdev, struct dp_packet **buffers, int *pcnt) { - int i; + int i, cnt = *pcnt, n_cnt = 0; if (!netdev->netdev_class->pop_header) { return EOPNOTSUPP; @@ -758,12 +758,18 @@ netdev_pop_header(struct netdev *netdev, struct dp_packet **buffers, int cnt) for (i = 0; i < cnt; i++) { int err; - err = netdev->netdev_class->pop_header(buffers[i]); + err = netdev->netdev_class->pop_header(&buffers[i]); if (err) { dp_packet_clear(buffers[i]); } } + for (i = 0; i < cnt; i++) { + if (buffers[i]) { + buffers[n_cnt++] = buffers[i]; + } + } + *pcnt = n_cnt; return 0; } diff --git a/lib/netdev.h b/lib/netdev.h index 622e2ae..99ea820 100644 --- a/lib/netdev.h +++ b/lib/netdev.h @@ -191,7 +191,7 @@ int netdev_push_header(const struct netdev *netdev, struct dp_packet **buffers, int cnt, const struct ovs_action_push_tnl *data); int netdev_pop_header(struct netdev *netdev, struct dp_packet **buffers, - int cnt); + int *pcnt); /* Hardware address. */ int netdev_set_etheraddr(struct netdev *, const struct eth_addr mac); diff --git a/lib/tnl-push-pop.c b/lib/tnl-push-pop.c index 463f37a..86023c2 100644 --- a/lib/tnl-push-pop.c +++ b/lib/tnl-push-pop.c @@ -387,8 +387,9 @@ pkt_metadata_init_tnl(struct pkt_metadata *md) } int -netdev_gre_pop_header(struct dp_packet *packet) +netdev_gre_pop_header(struct dp_packet **p_packet) { + struct dp_packet *packet = *p_packet; struct pkt_metadata *md = &packet->md; struct flow_tnl *tnl = &md->tunnel; int hlen = sizeof(struct eth_header) + 4; @@ -484,8 +485,9 @@ netdev_gre_build_header(const struct netdev *netdev, } int -netdev_vxlan_pop_header(struct dp_packet *packet) +netdev_vxlan_pop_header(struct dp_packet **p_packet) { + struct dp_packet *packet = *p_packet; struct pkt_metadata *md = &packet->md; struct flow_tnl *tnl = &md->tunnel; struct vxlanhdr *vxh; @@ -542,8 +544,9 @@ netdev_vxlan_build_header(const struct netdev *netdev, } int -netdev_geneve_pop_header(struct dp_packet *packet) +netdev_geneve_pop_header(struct dp_packet **p_packet) { + struct dp_packet *packet = *p_packet; struct pkt_metadata *md = &packet->md; struct flow_tnl *tnl = &md->tunnel; struct genevehdr *gnh; diff --git a/lib/tnl-push-pop.h b/lib/tnl-push-pop.h index 807cda6..be84ecd 100644 --- a/lib/tnl-push-pop.h +++ b/lib/tnl-push-pop.h @@ -30,7 +30,7 @@ void push_udp_header(struct dp_packet *packet, const struct ovs_action_push_tnl *data); int -netdev_geneve_pop_header(struct dp_packet *packet); +netdev_geneve_pop_header(struct dp_packet **p_packet); int netdev_gre_build_header(const struct netdev *netdev, @@ -40,14 +40,14 @@ void netdev_gre_push_header(struct dp_packet *packet, const struct ovs_action_push_tnl *data); int -netdev_gre_pop_header(struct dp_packet *packet); +netdev_gre_pop_header(struct dp_packet **packet); int netdev_vxlan_build_header(const struct netdev *netdev, struct ovs_action_push_tnl *data, const struct flow *tnl_flow); int -netdev_vxlan_pop_header(struct dp_packet *packet); +netdev_vxlan_pop_header(struct dp_packet **packet); void netdev_vport_range(struct unixctl_conn *conn, int argc, -- 1.8.3.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev