summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ovn/controller/pinctrl.c15
-rw-r--r--tests/ovn.at31
2 files changed, 43 insertions, 3 deletions
diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c
index 0906bc50e..17b173147 100644
--- a/ovn/controller/pinctrl.c
+++ b/ovn/controller/pinctrl.c
@@ -1285,6 +1285,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. */
@@ -1307,7 +1308,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);
@@ -1316,6 +1317,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);
}
@@ -1334,6 +1336,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. Consider port bindings with type
@@ -1352,8 +1355,9 @@ 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,
+ add_garp(name, ofport, tag, laddrs->ea,
laddrs->ipv4_addrs[i].addr);
}
free(name);
@@ -1380,7 +1384,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);
@@ -1410,6 +1414,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 94c8c0217..f051d86f5 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -8743,6 +8743,37 @@ $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv3/br-phys_n1-tx.pcap | trim_zeros
AT_CHECK([grep $garp hv3_br_phys_tx | sort], [0], [expout])
$PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv2/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv2_br_phys_tx
AT_CHECK([grep $garp hv2_br_phys_tx | sort], [0], [])
+
+# 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 --wait=sb lsp-set-options lrp0-rp router-port=lrp0 nat-addresses="router"
+
+as hv1 reset_pcap_file snoopvif hv1/snoopvif
+as hv2 reset_pcap_file br-phys_n1 hv2/br-phys_n1
+as hv3 reset_pcap_file br-phys_n1 hv3/br-phys_n1
+
+# 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="fffffffffffff00000000001810007de08060001080006040001f00000000001c0a80064000000000000c0a80064"
+echo $garp > expout
+
+$PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv1_snoopvif_tx
+AT_CHECK([sort hv1_snoopvif_tx], [0], [expout])
+$PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv3/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv3_br_phys_tx
+AT_CHECK([grep $garp hv3_br_phys_tx | sort], [0], [expout])
+$PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv2/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv2_br_phys_tx
+AT_CHECK([grep $garp hv2_br_phys_tx | sort], [0], [])
+
OVN_CLEANUP([hv1],[hv2],[hv3])
AT_CLEANUP