When available, use datapath 'clone' for patch port translation. Clone provides a stronger guarantee that packet will be restored after going through a patch port, Even in case the packet is NAT'd by the bridge behind the patch port.
Signed-off-by: Andy Zhou <[email protected]> --- ofproto/ofproto-dpif-xlate.c | 12 +++++++++++- tests/mpls-xlate.at | 2 +- tests/ofproto-dpif.at | 10 +++++----- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index de419402b9de..63040c002a00 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -577,6 +577,10 @@ static void xlate_xbundle_copy(struct xbridge *, struct xbundle *); static void xlate_xport_copy(struct xbridge *, struct xbundle *, struct xport *); static void xlate_xcfg_free(struct xlate_cfg *); + +struct compose_clone_info; +static struct compose_clone_info *compose_clone_open(struct xlate_ctx *); +static void compose_clone_close(struct xlate_ctx *, struct compose_clone_info *); /* Tracing helpers. */ @@ -3395,9 +3399,15 @@ compose_output_action__(struct xlate_ctx *ctx, ofp_port_t ofp_port, = ofproto_dpif_get_tables_version(ctx->xbridge->ofproto); if (!process_special(ctx, peer) && may_receive(peer, ctx)) { - if (xport_stp_forward_state(peer) && xport_rstp_forward_state(peer)) { + if (xport_stp_forward_state(peer) + && xport_rstp_forward_state(peer)) { + struct compose_clone_info *info; + + info = compose_clone_open(ctx); xlate_table_action(ctx, flow->in_port.ofp_port, 0, true, true, false); + compose_clone_close(ctx, info); + if (!ctx->freezing) { xlate_action_set(ctx); } diff --git a/tests/mpls-xlate.at b/tests/mpls-xlate.at index 9bbf22a99a3a..ebf1b7df582e 100644 --- a/tests/mpls-xlate.at +++ b/tests/mpls-xlate.at @@ -173,7 +173,7 @@ AT_CHECK([ovs-ofctl -O OpenFlow13 add-flow br1 in_port=1,ip,actions=dec_ttl,push dnl MPLS push+pop AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(100),eth(src=f8:bc:12:44:34:b6,dst=f8:bc:12:46:58:e0),eth_type(0x0800),ipv4(src=10.1.1.22,dst=10.0.0.3,proto=6,tos=0,ttl=64,frag=no),tcp(src=53295,dst=8080)'], [0], [stdout]) AT_CHECK([tail -1 stdout], [0], - [Datapath actions: set(ipv4(ttl=63)),push_mpls(label=0,tc=0,ttl=63,bos=1,eth_type=0x8847),3,pop_mpls(eth_type=0x800),set(ipv4(tos=0/0xfc,ttl=64)),1,1 + [Datapath actions: clone(set(ipv4(ttl=63)),push_mpls(label=0,tc=0,ttl=63,bos=1,eth_type=0x8847),3),1,1 ]) OVS_VSWITCHD_STOP diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at index 1f6cd8422e04..c26bc99974aa 100644 --- a/tests/ofproto-dpif.at +++ b/tests/ofproto-dpif.at @@ -7371,15 +7371,15 @@ dummy@ovs-dummy: hit:13 missed:2 ]) AT_CHECK([strip_ufid < ovs-vswitchd.log | filter_flow_install | strip_used], [0], [dnl -recirc_id(0),in_port(100),eth_type(0x0800),ipv4(frag=no), actions:101,3,2 -recirc_id(0),in_port(101),eth_type(0x0800),ipv4(frag=no), actions:100,2,3 +recirc_id(0),in_port(100),eth_type(0x0800),ipv4(frag=no), actions:clone(101,3),2 +recirc_id(0),in_port(101),eth_type(0x0800),ipv4(frag=no), actions:clone(100,2),3 ]) AT_CHECK([grep -e 'in_port(100).*packets:9' ovs-vswitchd.log | strip_ufid | filter_flow_dump], [0], [dnl -skb_priority(0/0),skb_mark(0/0),ct_state(0/0),ct_zone(0/0),ct_mark(0/0),ct_label(0/0),recirc_id(0),dp_hash(0/0),in_port(100),eth(src=50:54:00:00:00:05/00:00:00:00:00:00,dst=50:54:00:00:00:07/00:00:00:00:00:00),eth_type(0x0800),ipv4(src=192.168.0.1/0.0.0.0,dst=192.168.0.2/0.0.0.0,proto=1/0,tos=0/0,ttl=64/0,frag=no),icmp(type=8/0,code=0/0), packets:9, bytes:378, used:0.0s, actions:101,3,2 +skb_priority(0/0),skb_mark(0/0),ct_state(0/0),ct_zone(0/0),ct_mark(0/0),ct_label(0/0),recirc_id(0),dp_hash(0/0),in_port(100),eth(src=50:54:00:00:00:05/00:00:00:00:00:00,dst=50:54:00:00:00:07/00:00:00:00:00:00),eth_type(0x0800),ipv4(src=192.168.0.1/0.0.0.0,dst=192.168.0.2/0.0.0.0,proto=1/0,tos=0/0,ttl=64/0,frag=no),icmp(type=8/0,code=0/0), packets:9, bytes:378, used:0.0s, actions:clone(101,3),2 ]) AT_CHECK([grep -e 'in_port(101).*packets:4' ovs-vswitchd.log | strip_ufid | filter_flow_dump], [0], [dnl -skb_priority(0/0),skb_mark(0/0),ct_state(0/0),ct_zone(0/0),ct_mark(0/0),ct_label(0/0),recirc_id(0),dp_hash(0/0),in_port(101),eth(src=50:54:00:00:00:07/00:00:00:00:00:00,dst=50:54:00:00:00:05/00:00:00:00:00:00),eth_type(0x0800),ipv4(src=192.168.0.2/0.0.0.0,dst=192.168.0.1/0.0.0.0,proto=1/0,tos=0/0,ttl=64/0,frag=no),icmp(type=8/0,code=0/0), packets:4, bytes:168, used:0.0s, actions:100,2,3 +skb_priority(0/0),skb_mark(0/0),ct_state(0/0),ct_zone(0/0),ct_mark(0/0),ct_label(0/0),recirc_id(0),dp_hash(0/0),in_port(101),eth(src=50:54:00:00:00:07/00:00:00:00:00:00,dst=50:54:00:00:00:05/00:00:00:00:00:00),eth_type(0x0800),ipv4(src=192.168.0.2/0.0.0.0,dst=192.168.0.1/0.0.0.0,proto=1/0,tos=0/0,ttl=64/0,frag=no),icmp(type=8/0,code=0/0), packets:4, bytes:168, used:0.0s, actions:clone(100,2),3 ]) AT_CHECK([ovs-ofctl dump-ports br0 pbr0], [0], [dnl @@ -7436,7 +7436,7 @@ dummy@ovs-dummy: hit:0 missed:1 ]) AT_CHECK([strip_ufid < ovs-vswitchd.log | filter_flow_install | strip_used], [0], [dnl -recirc_id(0),in_port(100),eth_type(0x0800),ipv4(src=192.168.0.1,frag=no), actions:101,set(ipv4(src=255.255.255.254)),2 +recirc_id(0),in_port(100),eth_type(0x0800),ipv4(src=192.168.0.1,frag=no), actions:clone(101),set(ipv4(src=255.255.255.254)),2 ]) AT_CHECK([grep -e '|ofproto_dpif_xlate|WARN|' ovs-vswitchd.log | sed "s/^.*|WARN|//"], [0], [dnl -- 1.8.3.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
