Skip to content

Commit bf1a222

Browse files
crypticC0derdceara
authored andcommitted
Allow LR to send RAs through localnet port.
Modifies the rule responsible for dropping the MLF_LOCAL_ONLY packets to only drop them if the MLF_OVERRIDE_LOCAL_ONLY bit flag is not there. This does also include the addition of MLF_OVERRIDE_LOCAL_ONLY bitflag applied if a router announcement is being sent from either a gateway or distributed router. This is part of an ongoing unnumbered BGP effort. Backport specific patch for v24.03 Signed-off-by: MJ Ponsonby <[email protected]> Signed-off-by: Dumitru Ceara <[email protected]> (cherry picked from commit 744340f)
1 parent b48f7ea commit bf1a222

File tree

5 files changed

+123
-5
lines changed

5 files changed

+123
-5
lines changed

controller/physical.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1869,7 +1869,8 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name,
18691869
put_drop(debug, OFTABLE_CHECK_LOOPBACK, ofpacts_p);
18701870
match_outport_dp_and_port_keys(&match, dp_key, port_key);
18711871
match_set_reg_masked(&match, MFF_LOG_FLAGS - MFF_REG0,
1872-
MLF_LOCAL_ONLY, MLF_LOCAL_ONLY);
1872+
MLF_LOCAL_ONLY,
1873+
MLF_LOCAL_ONLY | MLF_OVERRIDE_LOCAL_ONLY);
18731874
ofctrl_add_flow(flow_table, OFTABLE_CHECK_LOOPBACK, 160,
18741875
binding->header_.uuid.parts[0], &match,
18751876
ofpacts_p, &binding->header_.uuid);

controller/pinctrl.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4108,6 +4108,7 @@ struct ipv6_ra_state {
41084108
struct ipv6_ra_config *config;
41094109
int64_t port_key;
41104110
int64_t metadata;
4111+
bool preserved;
41114112
bool delete_me;
41124113
};
41134114

@@ -4433,6 +4434,9 @@ ipv6_ra_send(struct rconn *swconn, struct ipv6_ra_state *ra)
44334434
put_load(dp_key, MFF_LOG_DATAPATH, 0, 64, &ofpacts);
44344435
put_load(port_key, MFF_LOG_INPORT, 0, 32, &ofpacts);
44354436
put_load(1, MFF_LOG_FLAGS, MLF_LOCAL_ONLY_BIT, 1, &ofpacts);
4437+
if (ra->preserved) {
4438+
put_load(1, MFF_LOG_FLAGS, MLF_OVERRIDE_LOCAL_ONLY_BIT, 1, &ofpacts);
4439+
}
44364440
struct ofpact_resubmit *resubmit = ofpact_put_RESUBMIT(&ofpacts);
44374441
resubmit->in_port = OFPP_CONTROLLER;
44384442
resubmit->table_id = OFTABLE_LOG_INGRESS_PIPELINE;
@@ -4543,8 +4547,11 @@ prepare_ipv6_ras(const struct shash *local_active_ports_ras,
45434547
* router port is connected to. The RA is injected
45444548
* into that logical switch port.
45454549
*/
4546-
ra->port_key = peer->tunnel_key;
4547-
ra->metadata = peer->datapath->tunnel_key;
4550+
ra->port_key = peer->tunnel_key;
4551+
ra->metadata = peer->datapath->tunnel_key;
4552+
ra->preserved = (!strcmp(pb->type,"l2gateway") ||
4553+
!strcmp(pb->type,"l3gateway") ||
4554+
!strcmp(pb->type,"chassisredirect"));
45484555
ra->delete_me = false;
45494556

45504557
/* pinctrl_handler thread will send the IPv6 RAs. */

include/ovn/logical-fields.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ enum mff_log_flags_bits {
8787
MLF_LOCALNET_BIT = 15,
8888
MLF_RX_FROM_TUNNEL_BIT = 16,
8989
MLF_ICMP_SNAT_BIT = 17,
90+
MLF_OVERRIDE_LOCAL_ONLY_BIT = 18,
9091
};
9192

9293
/* MFF_LOG_FLAGS_REG flag assignments */
@@ -142,6 +143,8 @@ enum mff_log_flags {
142143
MLF_RX_FROM_TUNNEL = (1 << MLF_RX_FROM_TUNNEL_BIT),
143144

144145
MLF_ICMP_SNAT = (1 << MLF_ICMP_SNAT_BIT),
146+
147+
MLF_OVERRIDE_LOCAL_ONLY = (1 << MLF_OVERRIDE_LOCAL_ONLY_BIT),
145148
};
146149

147150
/* OVN logical fields

ovn-architecture.7.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,8 +1546,10 @@
15461546
<p>
15471547
Table 41 matches and drops packets for which the logical input and
15481548
output ports are the same and the MLF_ALLOW_LOOPBACK flag is not
1549-
set. It also drops MLF_LOCAL_ONLY packets directed to a localnet port.
1550-
It resubmits other packets to table 42.
1549+
set. It also drops MLF_LOCAL_ONLY packets directed to a localnet port,
1550+
provided they aren't RAs sent from a gateway or distributed router
1551+
which is checked via the presence of the bitflag
1552+
MLF_OVERRIDE_LOCAL_ONLY. It resubmits other packets to table 42.
15511553
</p>
15521554
</li>
15531555

tests/ovn.at

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17088,6 +17088,111 @@ OVN_CLEANUP([hv1],[hv2])
1708817088
AT_CLEANUP
1708917089
])
1709017090

17091+
17092+
OVN_FOR_EACH_NORTHD([
17093+
AT_SETUP([IPv6 periodic gateway RA enabled for localnet adjacent switch ports])
17094+
ovn_start
17095+
17096+
net_add n1
17097+
sim_add hv1
17098+
sim_add hv2
17099+
as hv1
17100+
check ovs-vsctl add-br br-phys
17101+
check ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys
17102+
ovn_attach n1 br-phys 192.168.0.2
17103+
as hv2
17104+
check ovs-vsctl add-br br-phys
17105+
check ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys
17106+
ovn_attach n1 br-phys 192.168.0.3
17107+
17108+
check ovn-nbctl lr-add ro -- set Logical_Router ro options:chassis="hv1"
17109+
check ovn-nbctl lrp-add ro ro-sw 00:00:00:00:00:01 20.0.0.1/24
17110+
17111+
check ovn-nbctl ls-add sw
17112+
check ovn-nbctl lsp-add sw ln
17113+
check ovn-nbctl lsp-set-addresses ln unknown
17114+
check ovn-nbctl lsp-set-type ln localnet
17115+
check ovn-nbctl lsp-set-options ln network_name=phys
17116+
17117+
check ovn-nbctl lsp-add sw sw-ro
17118+
check ovn-nbctl lsp-set-type sw-ro router
17119+
check ovn-nbctl lsp-set-options sw-ro router-port=ro-sw
17120+
check ovn-nbctl lsp-set-addresses sw-ro 00:00:00:00:00:01
17121+
check ovn-nbctl lsp-add sw sw-p1
17122+
check ovn-nbctl lsp-set-addresses sw-p1 "00:00:00:00:00:02 aef0::200:ff:fe00:2"
17123+
check ovn-nbctl lsp-add sw sw-p2
17124+
check ovn-nbctl lsp-set-addresses sw-p2 "00:00:00:00:00:03 aef0::200:ff:fe00:3"
17125+
17126+
AT_CHECK([ovn-sbctl get Port_Binding ro-sw type | tr -d '\n'],[0],[l3gateway])
17127+
17128+
check ovn-nbctl set Logical_Router_Port ro-sw ipv6_ra_configs:send_periodic=true
17129+
check ovn-nbctl set Logical_Router_Port ro-sw ipv6_ra_configs:address_mode=slaac
17130+
check ovn-nbctl set Logical_Router_Port ro-sw ipv6_ra_configs:max_interval=1
17131+
check ovn-nbctl set Logical_Router_Port ro-sw ipv6_ra_configs:min_interval=1
17132+
17133+
for i in 1 2 ; do
17134+
as hv$i
17135+
check ovs-vsctl -- add-port br-int hv$i-vif1 -- \
17136+
set interface hv$i-vif1 external-ids:iface-id=sw-p$i \
17137+
options:tx_pcap=hv$i/vif1-tx.pcap \
17138+
options:rxq_pcap=hv$i/vif1-rx.pcap \
17139+
ofport-request=1
17140+
done
17141+
17142+
wait_for_ports_up
17143+
check ovn-nbctl --wait=hv sync
17144+
17145+
ra_received() {
17146+
$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" $1 | sed '/^ffffffffffff/d' | wc -l
17147+
}
17148+
17149+
ra_test() {
17150+
interface=$1
17151+
shift 1
17152+
local ra_packet=$(fmt_pkt "
17153+
Ether(src='00:00:00:00:00:01', dst='33:33:00:00:00:01') /
17154+
IPv6(dst='ff02::1', src='fe80::200:ff:fe00:1') /
17155+
ICMPv6ND_RA(chlim=255, prf=0, routerlifetime=65535) /
17156+
ICMPv6NDOptSrcLLAddr(lladdr='00:00:00:00:00:01')
17157+
")
17158+
intname="$interface"
17159+
17160+
for i in hv1 hv2 ; do
17161+
if echo "$interface" | grep -q -v "br"; then
17162+
intname="$i-$interface"
17163+
fi
17164+
echo $intname
17165+
as $i reset_pcap_file $intname $i/$interface
17166+
17167+
OVS_WAIT_WHILE([test 0 = $(ra_received $i/$interface-tx.pcap)])
17168+
17169+
$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" $i/$interface-tx.pcap > packets
17170+
sed -i '/^ffffffffffff/d' packets
17171+
17172+
echo ${ra_packet} | cut -c -112 > expout
17173+
AT_CHECK([head -1 packets | cut -c -112], [0], [expout])
17174+
17175+
# Skip ICMPv6 checksum.
17176+
echo ${ra_packet} | cut -c 117- > expout
17177+
AT_CHECK([head -1 packets | cut -c 117-], [0], [expout])
17178+
17179+
rm -f packets
17180+
as $i reset_pcap_file $intname $i/$interface
17181+
done
17182+
17183+
rm -f expected
17184+
}
17185+
17186+
# check that RAs are sent
17187+
ra_test vif1
17188+
17189+
# check that RAs are recived on br-phys
17190+
ra_test br-phys
17191+
17192+
OVN_CLEANUP([hv1],[hv2])
17193+
AT_CLEANUP
17194+
])
17195+
1709117196
OVN_FOR_EACH_NORTHD([
1709217197
AT_SETUP([ACL reject rule test])
1709317198
AT_KEYWORDS([acl-reject])

0 commit comments

Comments
 (0)