Skip to content

Commit

Permalink
OVN: Do not replace router port mac on gateway chassis.
Browse files Browse the repository at this point in the history
With 795d7f2 we have added
support for E-W routing on vlan backed networks by replacing
router port macs with chassis macs.

This replacement of router port mac need NOT be done on
gateway chassis for following reasons:

a. For N-S traffic, gateway chassis will respond to ARP
for the router port (to which it is attached) and
traffic will be using router port mac as destination mac.

b. Chassis redirect port is a centralized version of distributed
router port, hence we need not replace its mac with chassis mac
on the resident chassis.

This patch addresses the same.

Signed-off-by: Ankur Sharma <ankur.sharma@nutanix.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
  • Loading branch information
ankursharm authored and ovsrobot committed Aug 14, 2019
1 parent 7984c60 commit b5e56ef
Show file tree
Hide file tree
Showing 5 changed files with 355 additions and 21 deletions.
20 changes: 20 additions & 0 deletions controller/lport.c
Expand Up @@ -17,6 +17,7 @@

#include "lib/sset.h"
#include "lport.h"
#include "ha-chassis.h"
#include "hash.h"
#include "openvswitch/vlog.h"
#include "lib/ovn-sb-idl.h"
Expand Down Expand Up @@ -64,6 +65,25 @@ lport_lookup_by_key(struct ovsdb_idl_index *sbrec_datapath_binding_by_key,
return retval;
}

bool
lport_is_chassis_resident(struct ovsdb_idl_index *sbrec_port_binding_by_name,
const struct sbrec_chassis *chassis,
const struct sset *active_tunnels,
const char *port_name)
{
const struct sbrec_port_binding *pb
= lport_lookup_by_name(sbrec_port_binding_by_name, port_name);
if (!pb || !pb->chassis) {
return false;
}
if (strcmp(pb->type, "chassisredirect")) {
return pb->chassis == chassis;
} else {
return ha_chassis_group_is_active(pb->ha_chassis_group,
active_tunnels, chassis);
}
}

const struct sbrec_datapath_binding *
datapath_lookup_by_key(struct ovsdb_idl_index *sbrec_datapath_binding_by_key,
uint64_t dp_key)
Expand Down
5 changes: 5 additions & 0 deletions controller/lport.h
Expand Up @@ -48,5 +48,10 @@ const struct sbrec_datapath_binding *datapath_lookup_by_key(
const struct sbrec_multicast_group *mcgroup_lookup_by_dp_name(
struct ovsdb_idl_index *sbrec_multicast_group_by_name_datapath,
const struct sbrec_datapath_binding *, const char *name);
bool
lport_is_chassis_resident(struct ovsdb_idl_index *sbrec_port_binding_by_name,
const struct sbrec_chassis *chassis,
const struct sset *active_tunnels,
const char *port_name);

#endif /* controller/lport.h */
18 changes: 16 additions & 2 deletions controller/physical.c
Expand Up @@ -228,9 +228,12 @@ get_zone_ids(const struct sbrec_port_binding *binding,
}

static void
put_replace_router_port_mac_flows(const struct
put_replace_router_port_mac_flows(struct ovsdb_idl_index
*sbrec_port_binding_by_name,
const struct
sbrec_port_binding *localnet_port,
const struct sbrec_chassis *chassis,
const struct sset *active_tunnels,
const struct hmap *local_datapaths,
struct ofpbuf *ofpacts_p,
ofp_port_t ofport,
Expand Down Expand Up @@ -270,6 +273,16 @@ put_replace_router_port_mac_flows(const struct
struct eth_addr router_port_mac;
struct match match;
struct ofpact_mac *replace_mac;
char *cr_peer_name = xasprintf("cr-%s", rport_binding->logical_port);
if (lport_is_chassis_resident(sbrec_port_binding_by_name,
chassis, active_tunnels,
cr_peer_name)) {
/* If a router port's chassisredirect port is
* resident on this chassis, then we need not do mac replace. */
free(cr_peer_name);
continue;
}
free(cr_peer_name);

/* Table 65, priority 150.
* =======================
Expand Down Expand Up @@ -787,7 +800,8 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name,
&match, ofpacts_p, &binding->header_.uuid);

if (!strcmp(binding->type, "localnet")) {
put_replace_router_port_mac_flows(binding, chassis,
put_replace_router_port_mac_flows(sbrec_port_binding_by_name,
binding, chassis, active_tunnels,
local_datapaths, ofpacts_p,
ofport, flow_table);
}
Expand Down
20 changes: 1 addition & 19 deletions controller/pinctrl.c
Expand Up @@ -3755,24 +3755,6 @@ get_localnet_vifs_l3gwports(
sbrec_port_binding_index_destroy_row(target);
}

static bool
pinctrl_is_chassis_resident(struct ovsdb_idl_index *sbrec_port_binding_by_name,
const struct sbrec_chassis *chassis,
const struct sset *active_tunnels,
const char *port_name)
{
const struct sbrec_port_binding *pb
= lport_lookup_by_name(sbrec_port_binding_by_name, port_name);
if (!pb || !pb->chassis) {
return false;
}
if (strcmp(pb->type, "chassisredirect")) {
return pb->chassis == chassis;
} else {
return ha_chassis_group_is_active(pb->ha_chassis_group,
active_tunnels, chassis);
}
}

/* Extracts the mac, IPv4 and IPv6 addresses, and logical port from
* 'addresses' which should be of the format 'MAC [IP1 IP2 ..]
Expand Down Expand Up @@ -3853,7 +3835,7 @@ consider_nat_address(struct ovsdb_idl_index *sbrec_port_binding_by_name,
char *lport = NULL;
if (!extract_addresses_with_port(nat_address, laddrs, &lport)
|| (!lport && !strcmp(pb->type, "patch"))
|| (lport && !pinctrl_is_chassis_resident(
|| (lport && !lport_is_chassis_resident(
sbrec_port_binding_by_name, chassis,
active_tunnels, lport))) {
destroy_lport_addresses(laddrs);
Expand Down

0 comments on commit b5e56ef

Please sign in to comment.