diff options
author | Guoshuai Li <ligs@dtdream.com> | 2017-11-13 18:21:11 +0800 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2017-11-13 08:46:13 -0800 |
commit | ee72d59f151ede4a6f2e9ea3ecdfa6ce24d3600f (patch) | |
tree | fb2c0d1d6c4a5b86890a309828c0087bc4d20655 | |
parent | a7c8533a9bcdf5bfee9c13ba391117897034329f (diff) | |
download | openvswitch-ee72d59f151ede4a6f2e9ea3ecdfa6ce24d3600f.tar.gz |
ovn: Fix remote not receive GARP, when localnet Port has vlan tag.
When sending a localnet port with vlan, the GARP packet needs push_vlan.
Signed-off-by: Guoshuai Li <ligs@dtdream.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
-rw-r--r-- | ovn/controller/pinctrl.c | 16 | ||||
-rw-r--r-- | tests/ovn.at | 34 |
2 files changed, 47 insertions, 3 deletions
diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c index dc5279a87..bdf5f1cee 100644 --- a/ovn/controller/pinctrl.c +++ b/ovn/controller/pinctrl.c @@ -1001,6 +1001,7 @@ struct garp_data { long long int announce_time; /* Next announcement in ms. */ int backoff; /* Backoff for the next announcement. */ ofp_port_t ofport; /* ofport used to output this GARP. */ + int tag; /* VLAN tag of this GARP packet, or -1. */ }; /* Contains GARPs to be sent. */ @@ -1023,7 +1024,7 @@ destroy_send_garps(void) } static void -add_garp(const char *name, ofp_port_t ofport, +add_garp(const char *name, ofp_port_t ofport, int tag, const struct eth_addr ea, ovs_be32 ip) { struct garp_data *garp = xmalloc(sizeof *garp); @@ -1032,6 +1033,7 @@ add_garp(const char *name, ofp_port_t ofport, garp->announce_time = time_msec() + 1000; garp->backoff = 1; garp->ofport = ofport; + garp->tag = tag; shash_add(&send_garp_data, name, garp); } @@ -1050,6 +1052,7 @@ send_garp_update(const struct sbrec_port_binding *binding_rec, } ofp_port_t ofport = u16_to_ofp(simap_get(localnet_ofports, ld->localnet_port->logical_port)); + int tag = ld->localnet_port->n_tag ? *ld->localnet_port->tag : -1; volatile struct garp_data *garp = NULL; /* Update GARP for NAT IP if it exists. */ @@ -1066,8 +1069,10 @@ send_garp_update(const struct sbrec_port_binding *binding_rec, garp = shash_find_data(&send_garp_data, name); if (garp) { garp->ofport = ofport; + garp->tag = tag; } else { - add_garp(name, ofport, laddrs->ea, laddrs->ipv4_addrs[i].addr); + add_garp(name, ofport, tag, laddrs->ea, + laddrs->ipv4_addrs[i].addr); } free(name); } @@ -1090,7 +1095,7 @@ send_garp_update(const struct sbrec_port_binding *binding_rec, continue; } - add_garp(binding_rec->logical_port, ofport, + add_garp(binding_rec->logical_port, ofport, tag, laddrs.ea, laddrs.ipv4_addrs[0].addr); destroy_lport_addresses(&laddrs); @@ -1120,6 +1125,11 @@ send_garp(struct garp_data *garp, long long int current_time) compose_arp(&packet, ARP_OP_REQUEST, garp->ea, eth_addr_zero, true, garp->ipv4, garp->ipv4); + /* Compose a GARP request packet's vlan if exist. */ + if (garp->tag >= 0) { + eth_push_vlan(&packet, htons(ETH_TYPE_VLAN), htons(garp->tag)); + } + /* Compose actions. The garp request is output on localnet ofport. */ uint64_t ofpacts_stub[4096 / 8]; struct ofpbuf ofpacts = OFPBUF_STUB_INITIALIZER(ofpacts_stub); diff --git a/tests/ovn.at b/tests/ovn.at index 43b33c72a..48474a8a3 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -5332,6 +5332,40 @@ echo $expected > expout AT_CHECK([sort packets], [0], [expout]) cat packets +# change localnet port tag. +AT_CHECK([ovn-nbctl set Logical_Switch_Port ln_port tag=2014]) + +# wait for earlier changes to take effect +AT_CHECK([ovn-nbctl --timeout=3 --wait=sb sync], [0], [ignore]) + +# update nat-addresses option +ovn-nbctl --wait=sb lsp-set-options lrp0-rp router-port=lrp0 +ovn-nbctl lsp-set-options lrp0-rp router-port=lrp0 nat-addresses="f0:00:00:00:00:01 192.168.0.2" + +reset_pcap_file() { + local iface=$1 + local pcap_file=$2 + ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ +options:rxq_pcap=dummy-rx.pcap + rm -f ${pcap_file}*.pcap + ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ +options:rxq_pcap=${pcap_file}-rx.pcap +} + +as hv1 reset_pcap_file snoopvif hv1/snoopvif + +# Wait for packets to be received. +OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 100]) +trim_zeros() { + sed 's/\(00\)\{1,\}$//' +} + +garp="fffffffffffff00000000001810007de08060001080006040001f00000000001c0a80002000000000000c0a80002" +echo $garp > expout + +$PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros | uniq > hv1_snoopvif_tx +AT_CHECK([sort hv1_snoopvif_tx], [0], [expout]) + OVN_CLEANUP([hv1]) AT_CLEANUP |