dynamic-routing-advertise-vips lists single addresses on the load balancer, so a CMS has to keep one list per load balancer in step with the addresses it hands out. Whether an address may be advertised to the fabric is a property of the advertising router rather than of any single load balancer, and one load balancer that misses the option still announces a private VIP, which is hard to notice because the announcement itself looks ordinary. A NAT entry whose external IP is private leaks the same way.
Add the Logical_Router option dynamic-routing-advertise-prefixes, which a Logical_Router_Port can override the way dynamic-routing-redistribute is overridden. When set, a load balancer VIP or a NAT external IP is advertised and forwarded through a port only when the address falls inside one of the listed prefixes. A CMS lists the address space whose addresses may be advertised to the fabric, for example the subnet pools that share the address scope of the provider network, and addresses of private networks that overlap between tenants stay unadvertised no matter which load balancer or NAT entry carries them. An empty list advertises no load balancer VIP and no NAT external IP. The list of the load balancer applies as well, and a VIP is advertised only when both allow it. Host bits in an entry are ignored, and an entry that does not parse is ignored with a warning. The list is parsed once per advertising port. Test the filter on its own, on the router with a port override, together with the per load balancer list, and with NAT entries inside and outside the prefixes. Signed-off-by: Dmitrii Shcherbakov <[email protected]> --- NEWS | 4 + northd/en-advertised-route-sync.c | 225 +++++++++++++++++++++++++++--- ovn-nb.xml | 62 ++++++++ tests/ovn-northd.at | 169 +++++++++++++++++++++- 4 files changed, 435 insertions(+), 25 deletions(-) diff --git a/NEWS b/NEWS index 62e4ca349..f44a105e4 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,10 @@ Post v26.09.0 - Added a new "options:dynamic-routing-advertise-vips" key on the NB Load_Balancer table to limit route advertisement to a subset of the load balancer VIPs. + - Added a new "options:dynamic-routing-advertise-prefixes" key on the + NB Logical_Router table, with a Logical_Router_Port override, to + limit the advertisement of load balancer VIPs and NAT external IPs + to the listed CIDR prefixes. - Learn ARP sender hardware address (arp.sha) and IPv6 Neighbor Discovery link-layer addresses (nd.tll, nd.sll) into the FDB table in addition to eth.src. This allows VRRP virtual MACs to diff --git a/northd/en-advertised-route-sync.c b/northd/en-advertised-route-sync.c index 95f00cc78..9851e941a 100644 --- a/northd/en-advertised-route-sync.c +++ b/northd/en-advertised-route-sync.c @@ -522,6 +522,144 @@ ip46_in_prefix(const struct in6_addr *ip, const struct in6_addr *prefix, return ipv6_is_zero(&masked); } +/* Mask the host bits of prefix/plen in place, so that an entry with + * host bits set still names its network. */ +static void +ip46_prefix_network(struct in6_addr *prefix, unsigned int plen) +{ + if (IN6_IS_ADDR_V4MAPPED(prefix)) { + ovs_be32 network = in6_addr_get_mapped_ipv4(prefix) + & be32_prefix_mask(plen); + in6_addr_set_mapped_ipv4(prefix, network); + } else { + struct in6_addr mask = ipv6_create_mask(plen); + *prefix = ipv6_addr_bitand(prefix, &mask); + } +} + +/* The CIDR prefixes listed in dynamic-routing-advertise-prefixes of the + * advertising logical router port, or of its logical router when the port + * has no value of its own. */ +struct advertise_prefix { + struct in6_addr network; /* IPv4 stored as IPv4-mapped. */ + unsigned int plen; +}; + +struct advertise_prefixes { + bool set; /* False when the option is absent. */ + struct advertise_prefix *items; + size_t n; +}; + +static void +advertise_prefixes_destroy(struct advertise_prefixes *prefixes) +{ + free(prefixes->items); +} + +/* Fill prefixes with the networks listed in the advertising port's + * dynamic-routing-advertise-prefixes option, or in its router's option + * when the port has none. Parsed once per advertising port, every load + * balancer and NAT entry seen through the port reuses the result. + * prefixes->set stays false when the option is absent, in which case every + * address passes. An entry that does not parse is ignored with a + * warning. */ +static void +advertise_prefixes_init(const struct ovn_port *advertising_op, + struct advertise_prefixes *prefixes) +{ + *prefixes = (struct advertise_prefixes) { .set = false }; + if (!advertising_op->nbrp) { + return; + } + /* One rate limit per owner kind, so that a bad entry on a router is + * still reported after one on a port was. */ + static struct vlog_rate_limit rl_port = VLOG_RATE_LIMIT_INIT(5, 1); + static struct vlog_rate_limit rl_router = VLOG_RATE_LIMIT_INIT(5, 1); + bool from_router = false; + const char *owner_kind = "logical router port"; + const char *owner = advertising_op->key; + const char *list = smap_get(&advertising_op->nbrp->options, + "dynamic-routing-advertise-prefixes"); + if (!list && advertising_op->od->nbr) { + from_router = true; + owner_kind = "logical router"; + owner = advertising_op->od->nbr->name; + list = smap_get(&advertising_op->od->nbr->options, + "dynamic-routing-advertise-prefixes"); + } + if (!list) { + return; + } + prefixes->set = true; + + struct sset tokens = SSET_INITIALIZER(&tokens); + sset_from_delimited_string(&tokens, list, ", "); + + const char *token; + SSET_FOR_EACH (token, &tokens) { + struct in6_addr network; + unsigned int plen; + bool valid = ip46_parse_cidr(token, &network, &plen); + if (valid && IN6_IS_ADDR_V4MAPPED(&network) && strchr(token, ':')) { + /* An IPv4 prefix written in IPv4-mapped IPv6 notation carries + * an IPv6 prefix length. Keep it as the IPv4 length when it + * covers the mapped range, reject it otherwise. */ + valid = plen >= 96; + plen -= 96; + } + if (!valid) { + VLOG_WARN_RL(from_router ? &rl_router : &rl_port, + "Ignoring invalid prefix '%s' in " + "dynamic-routing-advertise-prefixes of %s %s", + token, owner_kind, owner); + continue; + } + ip46_prefix_network(&network, plen); + prefixes->items = xrealloc(prefixes->items, + (prefixes->n + 1) + * sizeof *prefixes->items); + prefixes->items[prefixes->n].network = network; + prefixes->items[prefixes->n].plen = plen; + prefixes->n++; + } + sset_destroy(&tokens); +} + +/* True when the option is absent or ip falls inside one of the + * prefixes. */ +static bool +ip_in_advertise_prefixes(const struct in6_addr *ip, + const struct advertise_prefixes *prefixes) +{ + if (!prefixes->set) { + return true; + } + for (size_t i = 0; i < prefixes->n; i++) { + if (ip46_in_prefix(ip, &prefixes->items[i].network, + prefixes->items[i].plen)) { + return true; + } + } + return false; +} + +/* True when the option is absent or vip falls inside one of the + * prefixes. A template VIP has no address and never passes a filter. */ +static bool +vip_in_advertise_prefixes(const struct ovn_lb_vip *vip, + const struct advertise_prefixes *prefixes) +{ + if (!prefixes->set) { + return true; + } + struct in6_addr ip; + if (!lb_vip_address(vip, &ip)) { + return false; + } + return ip_in_advertise_prefixes(&ip, prefixes); +} + /* A subnet of a logical router port network, collected to find address * space that more than one logical switch claims. */ struct subnet_ls { @@ -705,6 +843,7 @@ static void build_nat_route_for_port(const struct ovn_port *advertising_op, const struct lr_nat_record *lr_nat, const struct hmap *ls_ports, + const struct advertise_prefixes *prefixes, const struct sset *distributed_lb_routes, struct hmap *routes, const struct ovn_port *forwarding_port, @@ -723,6 +862,19 @@ build_nat_route_for_port(const struct ovn_port *advertising_op, continue; } + /* The external IP has to fall inside the advertised prefixes, the + * way a load balancer VIP has to. */ + struct in6_addr external_addr; + if (nat_entry_is_v6(nat)) { + external_addr = nat->ext_addrs.ipv6_addrs[0].addr; + } else { + in6_addr_set_mapped_ipv4(&external_addr, + nat->ext_addrs.ipv4_addrs[0].addr); + } + if (!ip_in_advertise_prefixes(&external_addr, prefixes)) { + continue; + } + /* Compare the canonical form of the external IP, the load balancer * VIP it may match was parsed and formatted the same way. */ const char *external_ip = @@ -780,9 +932,12 @@ build_nat_routes(const struct ovn_datapath *od, continue; } - build_nat_route_for_port(op, lr_nat, ls_ports, + struct advertise_prefixes prefixes; + advertise_prefixes_init(op, &prefixes); + build_nat_route_for_port(op, lr_nat, ls_ports, &prefixes, &data->distributed_lb_routes, &data->routes, NULL, NULL); + advertise_prefixes_destroy(&prefixes); } } @@ -813,22 +968,25 @@ build_nat_connected_routes( /* Track the peer datapath for any changes. */ dynamic_routes_track_od(data, peer_od); + struct advertise_prefixes prefixes; + advertise_prefixes_init(op, &prefixes); + /* This is a directly connected LR peer. */ if (peer_od->nbr) { const struct lr_stateful_record *peer_lr_stateful = lr_stateful_table_find_by_uuid(lr_stateful_table, peer_od->key); - if (!peer_lr_stateful) { - continue; - } - /* Advertise peer's NAT routes via the local port too, and * install forwarding routes so we can reach the * peer's external IPs. */ - build_nat_route_for_port(op, peer_lr_stateful->lrnat_rec, - ls_ports, &data->distributed_lb_routes, - &data->routes, op->peer, - &data->parsed_routes); + if (peer_lr_stateful) { + build_nat_route_for_port(op, peer_lr_stateful->lrnat_rec, + ls_ports, &prefixes, + &data->distributed_lb_routes, + &data->routes, op->peer, + &data->parsed_routes); + } + advertise_prefixes_destroy(&prefixes); continue; } @@ -852,13 +1010,15 @@ build_nat_connected_routes( * install forwarding routes so we can reach the * peer's external IPs. */ build_nat_route_for_port(op, peer_lr_stateful->lrnat_rec, - ls_ports, &data->distributed_lb_routes, + ls_ports, &prefixes, + &data->distributed_lb_routes, &data->routes, rp->peer, &data->parsed_routes); /* Track the LR datapath on the other side of LS * for any changes. */ dynamic_routes_track_od(data, rp->peer->od); } + advertise_prefixes_destroy(&prefixes); } } @@ -872,9 +1032,12 @@ build_nat_connected_routes( * in place of a per-backend LSP. The forwarding route is emitted once * per VIP regardless of backend count: the data-plane forwarding * decision is independent of which backend ends up serving the flow. - * Every VIP of a distributed LB is recorded in distributed_lb_routes with - * owner_lr, the logical router the LB is attached to, so that - * build_nat_route_for_port() can skip the NAT route for it. */ + * Every advertised VIP of a distributed LB is recorded in + * distributed_lb_routes with owner_lr, the logical router the LB is + * attached to, so that build_nat_route_for_port() can skip the NAT + * route for it. A VIP is advertised only when both the load + * balancer's dynamic-routing-advertise-vips list and the advertising + * port's dynamic-routing-advertise-prefixes list allow it. */ static void build_lb_routes_for_lb(const struct ovn_port *advertising_op, const struct ovn_port *fallback_tracked_port, @@ -882,6 +1045,7 @@ build_lb_routes_for_lb(const struct ovn_port *advertising_op, const struct nbrec_load_balancer *nbrec_lb, const struct hmap *lb_datapaths_map, const struct hmap *ls_ports, + const struct advertise_prefixes *prefixes, struct dup_subnets *dup_subnets, struct sset *distributed_lb_routes, struct hmap *routes, @@ -918,6 +1082,10 @@ build_lb_routes_for_lb(const struct ovn_port *advertising_op, continue; } + if (!vip_in_advertise_prefixes(vip, prefixes)) { + continue; + } + warn_vip_in_duplicated_subnet(vip, nbrec_lb, advertising_op, dup_subnets); @@ -1004,6 +1172,7 @@ build_lb_lr_routes(const struct ovn_port *advertising_op, const struct nbrec_logical_router *peer_lr_nbr, const struct hmap *lb_datapaths_map, const struct hmap *ls_ports, + const struct advertise_prefixes *prefixes, struct dup_subnets *dup_subnets, struct sset *distributed_lb_routes, struct hmap *routes, @@ -1019,7 +1188,8 @@ build_lb_lr_routes(const struct ovn_port *advertising_op, uuidset_insert(&visited, &lb->header_.uuid); build_lb_routes_for_lb(advertising_op, fallback_tracked_port, peer_lr_nbr, lb, lb_datapaths_map, ls_ports, - dup_subnets, distributed_lb_routes, routes, + prefixes, dup_subnets, + distributed_lb_routes, routes, parsed_routes_out); } @@ -1034,7 +1204,7 @@ build_lb_lr_routes(const struct ovn_port *advertising_op, uuidset_insert(&visited, &lb->header_.uuid); build_lb_routes_for_lb(advertising_op, fallback_tracked_port, peer_lr_nbr, lb, lb_datapaths_map, - ls_ports, dup_subnets, + ls_ports, prefixes, dup_subnets, distributed_lb_routes, routes, parsed_routes_out); } @@ -1069,12 +1239,16 @@ build_lb_connected_routes(const struct ovn_datapath *od, /* Track the peer datapath for any changes. */ dynamic_routes_track_od(data, peer_od); + struct advertise_prefixes prefixes; + advertise_prefixes_init(op, &prefixes); + /* This is directly connected LR peer. */ if (peer_od->nbr) { build_lb_lr_routes(op, op->peer, peer_od->nbr, - lb_datapaths_map, ls_ports, dup_subnets, - &data->distributed_lb_routes, + lb_datapaths_map, ls_ports, &prefixes, + dup_subnets, &data->distributed_lb_routes, &data->routes, &data->parsed_routes); + advertise_prefixes_destroy(&prefixes); continue; } @@ -1088,13 +1262,14 @@ build_lb_connected_routes(const struct ovn_datapath *od, continue; } build_lb_lr_routes(op, rp->peer, rp->peer->od->nbr, - lb_datapaths_map, ls_ports, dup_subnets, - &data->distributed_lb_routes, + lb_datapaths_map, ls_ports, &prefixes, + dup_subnets, &data->distributed_lb_routes, &data->routes, &data->parsed_routes); /* Track the LR datapath on the other side of LS * for any changes. */ dynamic_routes_track_od(data, rp->peer->od); } + advertise_prefixes_destroy(&prefixes); } } @@ -1116,20 +1291,24 @@ build_lb_routes(const struct ovn_datapath *od, continue; } + struct advertise_prefixes prefixes; + advertise_prefixes_init(op, &prefixes); + if (od->is_gw_router) { build_lb_lr_routes(op, NULL, od->nbr, - lb_datapaths_map, ls_ports, dup_subnets, - &data->distributed_lb_routes, + lb_datapaths_map, ls_ports, &prefixes, + dup_subnets, &data->distributed_lb_routes, &data->routes, NULL); } else { struct ovn_port *dgp; VECTOR_FOR_EACH (&od->l3dgw_ports, dgp) { build_lb_lr_routes(op, dgp, od->nbr, - lb_datapaths_map, ls_ports, dup_subnets, - &data->distributed_lb_routes, + lb_datapaths_map, ls_ports, &prefixes, + dup_subnets, &data->distributed_lb_routes, &data->routes, NULL); } } + advertise_prefixes_destroy(&prefixes); } } diff --git a/ovn-nb.xml b/ovn-nb.xml index 718a46b2f..d0a606c2e 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -3695,6 +3695,43 @@ or </p> </column> + <column name="options" key="dynamic-routing-advertise-prefixes"> + <p> + Only relevant if <ref column="options" key="dynamic-routing"/> + is set to <code>true</code> and <code>lb</code> or + <code>nat</code> is in + <ref column="options" key="dynamic-routing-redistribute"/>. + </p> + + <p> + A comma or space separated list of CIDR prefixes. When set, a + load balancer VIP or a NAT external IP is advertised and + forwarded through a port of this router only when the address + falls inside one of the prefixes. A CMS uses this to advertise + the addresses of its own address space only, for example the + subnet pools that share the address scope of the provider + network, while addresses of private networks that overlap + between tenants stay unadvertised whichever load balancer or + NAT entry carries them. An empty list advertises no load + balancer VIP and no NAT external IP. The list of + <ref column="options" key="dynamic-routing-advertise-vips" + table="Load_Balancer"/> applies as well, and a VIP is advertised + only when both allow it. An entry that does not parse is + ignored with a warning in the <code>ovn-northd</code> log, and + the host bits of an entry are ignored. By default every + address is advertised. Prefer this option to a list on every + load balancer. The address space is configured once, and a + load balancer without a list of its own cannot leak an + address through a port of this router. + </p> + + <p> + This value can be overwritten on a per LRP basis using + <ref column="options" key="dynamic-routing-advertise-prefixes" + table="Logical_Router_Port"/> on the Logical_Router_Port. + </p> + </column> + <column name="options" key="dynamic-routing-vrf-name" type='{"type": "string"}'> <p> @@ -4947,6 +4984,31 @@ or </p> </column> + <column name="options" key="dynamic-routing-advertise-prefixes"> + <p> + Only relevant if <ref column="options" key="dynamic-routing"/> + is set to <code>true</code> and <code>lb</code> or + <code>nat</code> is in + <ref column="options" key="dynamic-routing-redistribute"/>. + </p> + + <p> + A comma or space separated list of CIDR prefixes. When set, a + load balancer VIP or a NAT external IP is advertised and + forwarded through this port only when the address falls inside + one of the prefixes, see <ref column="options" + key="dynamic-routing-advertise-prefixes" + table="Logical_Router"/>. + </p> + + <p> + If not set the value from <ref column="options" + key="dynamic-routing-advertise-prefixes" + table="Logical_Router"/> on the <ref table="Logical_Router"/> will + be used. + </p> + </column> + <column name="options" key="dynamic-routing-maintain-vrf" type='{"type": "boolean"}'> <p> diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at index 8d23f011c..565b3ec78 100644 --- a/tests/ovn-northd.at +++ b/tests/ovn-northd.at @@ -25728,9 +25728,10 @@ check_row_count Advertised_Route 2 ip_prefix='"172.16.0.20"' check_row_count Advertised_Route 2 ip_prefix='"10.0.0.10"' # The private VIP of lbB falls inside a subnet that priv1 and priv2 -# share, so northd warns. +# share, so northd warns. The order of the two switches follows the +# router iteration and is not fixed. AT_CHECK([grep -q "VIP 10.0.0.10 of load balancer lbB advertised through lr0-up falls inside subnet 10.0.0.0/24" northd/ovn-northd.log]) -AT_CHECK([grep -q "falls inside subnet 10.0.0.0/24 used on logical switches priv1 and priv2" northd/ovn-northd.log]) +AT_CHECK([grep -qE "falls inside subnet 10.0.0.0/24 used on logical switches (priv1 and priv2|priv2 and priv1)" northd/ovn-northd.log]) # The private VIP of lbA is not advertised, so it must not warn. AT_CHECK([grep -q "WARN.*of load balancer lbA" northd/ovn-northd.log], [1]) @@ -25760,3 +25761,167 @@ check_row_count Advertised_Route 2 ip_prefix='"172.16.0.10"' OVN_CLEANUP_NORTHD AT_CLEANUP ]) + +OVN_FOR_EACH_NORTHD_NO_HV([ +AT_SETUP([dynamic-routing - advertised prefixes filter]) +AT_KEYWORDS([dynamic-routing]) +ovn_start + +# lr0 redistributes lb,nat toward the shared LS "up". lr1 owns a +# distributed load balancer with a floating IP VIP 172.16.1.10 and a +# private VIP 192.168.1.100, the way a CMS adds the floating IP as an +# extra VIP, a NAT entry for the floating IP and a NAT entry with a +# private external IP. dynamic-routing-advertise-prefixes lists the +# address space whose addresses may be advertised to the fabric, the +# way a CMS lists the subnet pools that share the address scope of the +# provider network. + +check ovn-nbctl lr-add lr0 +check ovn-nbctl set Logical_Router lr0 \ + options:dynamic-routing=true \ + options:chassis=hv1 +check ovn-nbctl lrp-add lr0 lr0-up 00:00:00:00:00:01 +check ovn-nbctl lrp-set-options lr0-up dynamic-routing-redistribute=lb,nat +check ovn-nbctl ls-add up +check ovn-nbctl lsp-add-router-port up up-lr0 lr0-up + +check ovn-nbctl lr-add lr1 +check ovn-nbctl lrp-add lr1 lr1-up 00:00:00:00:00:02 10.0.0.1/24 +check ovn-nbctl lrp-set-gateway-chassis lr1-up hv1 +check ovn-nbctl lsp-add-router-port up up-lr1 lr1-up +check ovn-nbctl lrp-add lr1 lr1-be 00:00:00:00:00:03 192.168.1.1/24 +check ovn-nbctl ls-add be +check ovn-nbctl lsp-add-router-port be be-lr1 lr1-be +check ovn-nbctl lsp-add be be-vm1 +check ovn-nbctl lsp-set-addresses be-vm1 "00:00:00:00:01:01 192.168.1.10" +check ovn-nbctl lsp-add be be-vm2 +check ovn-nbctl lsp-set-addresses be-vm2 "00:00:00:00:01:02 192.168.1.11" + +check ovn-nbctl \ + -- lb-add lb0 172.16.1.10:80 192.168.1.10:80,192.168.1.11:80 \ + -- lb-add lb0 192.168.1.100:80 192.168.1.10:80,192.168.1.11:80 \ + -- set Load_Balancer lb0 options:distributed=true \ + ip_port_mappings:192.168.1.10="be-vm1:192.168.1.1" \ + ip_port_mappings:192.168.1.11="be-vm2:192.168.1.1" \ + -- lr-lb-add lr1 lb0 +check ovn-nbctl lr-nat-add lr1 dnat_and_snat 172.16.1.10 192.168.1.10 +check ovn-nbctl lr-nat-add lr1 dnat_and_snat 192.168.1.200 192.168.1.20 +check ovn-nbctl --wait=sb sync + +pb_lr1_up=$(fetch_column Port_Binding _uuid logical_port=lr1-up) + +# Without the option every VIP and NAT external IP is advertised: four +# LB routes and the NAT route of the private external IP. The NAT route +# of the floating IP is suppressed by the load balancer routes. +check_row_count Advertised_Route 5 +check_row_count Advertised_Route 2 ip_prefix='"172.16.1.10"' +check_row_count Advertised_Route 2 ip_prefix='"192.168.1.100"' +check_row_count Advertised_Route 1 \ + ip_prefix='"192.168.1.200"' tracked_port=$pb_lr1_up + +# Only addresses inside the listed prefixes are advertised and +# forwarded. The floating IP keeps its per-backend routes and stays +# suppressed as a NAT route. The private VIP and the NAT entry with a +# private external IP are not advertised. +check ovn-nbctl --wait=sb lrp-set-options lr0-up \ + dynamic-routing-redistribute=lb,nat \ + dynamic-routing-advertise-prefixes="172.16.1.0/24" +check_row_count Advertised_Route 2 +check_row_count Advertised_Route 2 ip_prefix='"172.16.1.10"' +check_row_count Advertised_Route 0 ip_prefix='"192.168.1.100"' +check_row_count Advertised_Route 0 ip_prefix='"192.168.1.200"' +ovn-sbctl lflow-list lr0 > lr0_flows +AT_CHECK([grep -c 'lr_in_ip_routing.*172.16.1.10/32' lr0_flows], [0], [1 +]) +AT_CHECK([grep -c 'lr_in_ip_routing.*192.168.1.100/32' lr0_flows], [1], [0 +]) +AT_CHECK([grep -c 'lr_in_ip_routing.*192.168.1.200/32' lr0_flows], [1], [0 +]) + +# Host bits are ignored, so this is the same prefix as above. +check ovn-nbctl --wait=sb lrp-set-options lr0-up \ + dynamic-routing-redistribute=lb,nat \ + dynamic-routing-advertise-prefixes="172.16.1.9/24" +check_row_count Advertised_Route 2 + +# An entry that does not parse is ignored with a warning. +check ovn-nbctl --wait=sb lrp-set-options lr0-up \ + dynamic-routing-redistribute=lb,nat \ + dynamic-routing-advertise-prefixes="bogus,172.16.1.0/24" +check_row_count Advertised_Route 2 +AT_CHECK([grep -q "Ignoring invalid prefix 'bogus' in dynamic-routing-advertise-prefixes of logical router port lr0-up" northd/ovn-northd.log]) + +# An IPv4 prefix in IPv4-mapped IPv6 notation is the same prefix again. A +# mapped prefix shorter than the mapped range is not a prefix of IPv4 +# addresses and is ignored like any invalid entry. Its warning shares the +# rate limit of the one above, so only the rows are checked here. +check ovn-nbctl --wait=sb lrp-set-options lr0-up \ + dynamic-routing-redistribute=lb,nat \ + dynamic-routing-advertise-prefixes="::ffff:172.16.1.0/120" +check_row_count Advertised_Route 2 +check ovn-nbctl --wait=sb lrp-set-options lr0-up \ + dynamic-routing-redistribute=lb,nat \ + dynamic-routing-advertise-prefixes="::ffff:172.16.1.0/64,172.16.1.0/24" +check_row_count Advertised_Route 2 +check ovn-nbctl --wait=sb lrp-set-options lr0-up \ + dynamic-routing-redistribute=lb,nat \ + dynamic-routing-advertise-prefixes="::ffff:172.16.1.0/24" +check_row_count Advertised_Route 0 + +# A prefix of the same address space as the private addresses lets them +# through, the case of a subnet pool that shares the provider address +# scope. +check ovn-nbctl --wait=sb lrp-set-options lr0-up \ + dynamic-routing-redistribute=lb,nat \ + dynamic-routing-advertise-prefixes="172.16.1.0/24,192.168.1.0/24" +check_row_count Advertised_Route 5 +check_row_count Advertised_Route 2 ip_prefix='"192.168.1.100"' +check_row_count Advertised_Route 1 ip_prefix='"192.168.1.200"' + +# The per-LB list applies as well, and a VIP is advertised only when +# both allow it. Listing only the private VIP in the load balancer +# blocks the floating IP, so its NAT route returns, inside the prefixes. +check ovn-nbctl --wait=sb set Load_Balancer lb0 \ + options:dynamic-routing-advertise-vips="192.168.1.100" +check_row_count Advertised_Route 4 +check_row_count Advertised_Route 1 \ + ip_prefix='"172.16.1.10"' tracked_port=$pb_lr1_up +check ovn-nbctl --wait=sb remove Load_Balancer lb0 options \ + dynamic-routing-advertise-vips +check_row_count Advertised_Route 5 + +# An empty list advertises no VIP and no NAT external IP. +check ovn-nbctl --wait=sb lrp-set-options lr0-up \ + dynamic-routing-redistribute=lb,nat \ + dynamic-routing-advertise-prefixes='""' +check_row_count Advertised_Route 0 + +# The router value is the default for every port of the router, and the +# port value overrides it. +check ovn-nbctl --wait=sb remove Logical_Router_Port lr0-up options \ + dynamic-routing-advertise-prefixes +check_row_count Advertised_Route 5 +check ovn-nbctl --wait=sb set Logical_Router lr0 \ + options:dynamic-routing-advertise-prefixes="172.16.1.0/24" +check_row_count Advertised_Route 2 +check_row_count Advertised_Route 2 ip_prefix='"172.16.1.10"' +check ovn-nbctl --wait=sb lrp-set-options lr0-up \ + dynamic-routing-redistribute=lb,nat \ + dynamic-routing-advertise-prefixes="172.16.1.0/24,192.168.1.0/24" +check_row_count Advertised_Route 5 +check ovn-nbctl --wait=sb remove Logical_Router_Port lr0-up options \ + dynamic-routing-advertise-prefixes +check_row_count Advertised_Route 2 +check ovn-nbctl --wait=sb set Logical_Router lr0 \ + options:dynamic-routing-advertise-prefixes="bogus" +check_row_count Advertised_Route 0 +AT_CHECK([grep -q "Ignoring invalid prefix 'bogus' in dynamic-routing-advertise-prefixes of logical router lr0" northd/ovn-northd.log]) + +# Removing the option advertises every address again. +check ovn-nbctl --wait=sb remove Logical_Router lr0 options \ + dynamic-routing-advertise-prefixes +check_row_count Advertised_Route 5 + +OVN_CLEANUP_NORTHD +AT_CLEANUP +]) -- 2.53.0 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
