Skip to content

Commit

Permalink
ovn-nb: Rename Port_Bindings 'macs' column to 'addresses'.
Browse files Browse the repository at this point in the history
In an upcoming commit this column will also support IP+MAC pairs.

Signed-off-by: Ben Pfaff <[email protected]>
Acked-by: Justin Pettit <[email protected]>
  • Loading branch information
blp committed Oct 17, 2015
1 parent ae9ba6b commit 2fa326a
Show file tree
Hide file tree
Showing 17 changed files with 116 additions and 114 deletions.
17 changes: 9 additions & 8 deletions ovn/northd/ovn-northd.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,8 @@ ovn_port_update_sbrec(const struct ovn_port *op)
sbrec_port_binding_set_datapath(op->sb, op->od->sb);
sbrec_port_binding_set_parent_port(op->sb, op->nb->parent_name);
sbrec_port_binding_set_tag(op->sb, op->nb->tag, op->nb->n_tag);
sbrec_port_binding_set_mac(op->sb, (const char **) op->nb->macs,
op->nb->n_macs);
sbrec_port_binding_set_mac(op->sb, (const char **) op->nb->addresses,
op->nb->n_addresses);
}

static void
Expand Down Expand Up @@ -919,14 +919,14 @@ build_lflows(struct northd_context *ctx, struct hmap *datapaths,

/* Ingress table 3: Destination lookup, unicast handling (priority 50), */
HMAP_FOR_EACH (op, key_node, ports) {
for (size_t i = 0; i < op->nb->n_macs; i++) {
for (size_t i = 0; i < op->nb->n_addresses; i++) {
struct eth_addr mac;

if (eth_addr_from_string(op->nb->macs[i], &mac)) {
if (eth_addr_from_string(op->nb->addresses[i], &mac)) {
struct ds match, actions;

ds_init(&match);
ds_put_format(&match, "eth.dst == %s", op->nb->macs[i]);
ds_put_format(&match, "eth.dst == %s", op->nb->addresses[i]);

ds_init(&actions);
ds_put_cstr(&actions, "outport = ");
Expand All @@ -936,16 +936,17 @@ build_lflows(struct northd_context *ctx, struct hmap *datapaths,
ds_cstr(&match), ds_cstr(&actions));
ds_destroy(&actions);
ds_destroy(&match);
} else if (!strcmp(op->nb->macs[i], "unknown")) {
} else if (!strcmp(op->nb->addresses[i], "unknown")) {
if (lport_is_enabled(op->nb)) {
ovn_multicast_add(&mcgroups, &mc_unknown, op);
op->od->has_unknown = true;
}
} else {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);

VLOG_INFO_RL(&rl, "%s: invalid syntax '%s' in macs column",
op->nb->name, op->nb->macs[i]);
VLOG_INFO_RL(&rl,
"%s: invalid syntax '%s' in addresses column",
op->nb->name, op->nb->addresses[i]);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions ovn/ovn-nb.ovsschema
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "OVN_Northbound",
"version": "1.0.0",
"cksum": "3156743511 4790",
"cksum": "1432579799 4805",
"tables": {
"Logical_Switch": {
"columns": {
Expand Down Expand Up @@ -39,9 +39,9 @@
"minInteger": 1,
"maxInteger": 4095},
"min": 0, "max": 1}},
"macs": {"type": {"key": "string",
"min": 0,
"max": "unlimited"}},
"addresses": {"type": {"key": "string",
"min": 0,
"max": "unlimited"}},
"port_security": {"type": {"key": "string",
"min": 0,
"max": "unlimited"}},
Expand Down
2 changes: 1 addition & 1 deletion ovn/ovn-nb.xml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
ingress and egress traffic dropped.
</column>

<column name="macs">
<column name="addresses">
The logical port's own Ethernet address or addresses, each in the form
<var>xx</var>:<var>xx</var>:<var>xx</var>:<var>xx</var>:<var>xx</var>:<var>xx</var>.
Like a physical Ethernet NIC, a logical port ordinarily has a single
Expand Down
14 changes: 7 additions & 7 deletions ovn/utilities/ovn-nbctl.8.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,17 @@
nothing.
</dd>

<dt><code>lport-set-macs</code> <var>lport</var> [<var>mac</var>]...</dt>
<dt><code>lport-set-addresses</code> <var>lport</var> [<var>address</var>]...</dt>
<dd>
Sets the MACs associated with <var>lport</var> to
<var>mac</var>. Multiple MACs may be sets by using multiple
<var>mac</var> arguments. If no <var>mac</var> argument is
given, <var>lport</var> will have no MACs associated with it.
Sets the addresses associated with <var>lport</var> to
<var>address</var>. Multiple MACs may be sets by using multiple
<var>address</var> arguments. If no <var>mac</var> argument is given,
<var>lport</var> will have no addresses associated with it.
</dd>

<dt><code>lport-get-macs</code> <var>lport</var></dt>
<dt><code>lport-get-addresses</code> <var>lport</var></dt>
<dd>
Lists all the MACs associated with <var>lport</var> on standard
Lists all the addresses associated with <var>lport</var> on standard
output, one per line.
</dd>

Expand Down
41 changes: 21 additions & 20 deletions ovn/utilities/ovn-nbctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ Logical port commands:\n\
lport-list LSWITCH print the names of all logical ports on LSWITCH\n\
lport-get-parent LPORT get the parent of LPORT if set\n\
lport-get-tag LPORT get the LPORT's tag if set\n\
lport-set-macs LPORT [MAC]...\n\
set MAC addresses for LPORT.\n\
lport-get-macs LPORT get a list of MAC addresses on LPORT\n\
lport-set-addresses LPORT [ADDRESS]...\n\
set addresses for LPORT.\n\
lport-get-addresses LPORT get a list of MAC addresses on LPORT\n\
lport-set-port-security LPORT [ADDRS]...\n\
set port security addresses for LPORT.\n\
lport-get-port-security LPORT get LPORT's port security addresses\n\
Expand Down Expand Up @@ -402,10 +402,10 @@ print_lswitch(const struct nbrec_logical_switch *lswitch, struct ds *s)
if (lport->n_tag) {
ds_put_format(s, " tag: %"PRIu64"\n", lport->tag[0]);
}
if (lport->n_macs) {
ds_put_cstr(s, " macs:");
for (size_t j = 0; j < lport->n_macs; j++) {
ds_put_format(s, " %s", lport->macs[j]);
if (lport->n_addresses) {
ds_put_cstr(s, " addresses:");
for (size_t j = 0; j < lport->n_addresses; j++) {
ds_put_format(s, " %s", lport->addresses[j]);
}
ds_put_char(s, '\n');
}
Expand Down Expand Up @@ -652,7 +652,7 @@ nbctl_lport_get_tag(struct ctl_context *ctx)
}

static void
nbctl_lport_set_macs(struct ctl_context *ctx)
nbctl_lport_set_addresses(struct ctl_context *ctx)
{
const char *id = ctx->argv[1];
const struct nbrec_logical_port *lport;
Expand All @@ -662,16 +662,16 @@ nbctl_lport_set_macs(struct ctl_context *ctx)
return;
}

nbrec_logical_port_set_macs(lport,
nbrec_logical_port_set_addresses(lport,
(const char **) ctx->argv + 2, ctx->argc - 2);
}

static void
nbctl_lport_get_macs(struct ctl_context *ctx)
nbctl_lport_get_addresses(struct ctl_context *ctx)
{
const char *id = ctx->argv[1];
const struct nbrec_logical_port *lport;
struct svec macs;
struct svec addresses;
const char *mac;
size_t i;

Expand All @@ -680,15 +680,15 @@ nbctl_lport_get_macs(struct ctl_context *ctx)
return;
}

svec_init(&macs);
for (i = 0; i < lport->n_macs; i++) {
svec_add(&macs, lport->macs[i]);
svec_init(&addresses);
for (i = 0; i < lport->n_addresses; i++) {
svec_add(&addresses, lport->addresses[i]);
}
svec_sort(&macs);
SVEC_FOR_EACH(i, mac, &macs) {
svec_sort(&addresses);
SVEC_FOR_EACH(i, mac, &addresses) {
ds_put_format(&ctx->output, "%s\n", mac);
}
svec_destroy(&macs);
svec_destroy(&addresses);
}

static void
Expand Down Expand Up @@ -1308,9 +1308,10 @@ static const struct ctl_command_syntax nbctl_commands[] = {
"", RO },
{ "lport-get-tag", 1, 1, "LPORT", NULL, nbctl_lport_get_tag, NULL, "",
RO },
{ "lport-set-macs", 1, INT_MAX, "LPORT [MAC]...", NULL,
nbctl_lport_set_macs, NULL, "", RW },
{ "lport-get-macs", 1, 1, "LPORT", NULL, nbctl_lport_get_macs, NULL,
{ "lport-set-addresses", 1, INT_MAX, "LPORT [ADDRESS]...", NULL,
nbctl_lport_set_addresses, NULL, "", RW },
{ "lport-get-addresses", 1, 1, "LPORT", NULL,
nbctl_lport_get_addresses, NULL,
"", RO },
{ "lport-set-port-security", 0, INT_MAX, "LPORT [ADDRS]...", NULL,
nbctl_lport_set_port_security, NULL, "", RW },
Expand Down
18 changes: 9 additions & 9 deletions tests/ovn-controller-vtep.at
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ OVN_CONTROLLER_VTEP_START
# creates a simple logical network with the vtep device and a fake hv chassis
# 'ch0'.
AT_CHECK([ovn-nbctl lport-add br-test vif0])
AT_CHECK([ovn-nbctl lport-set-macs vif0 f0:ab:cd:ef:01:02])
AT_CHECK([ovn-nbctl lport-set-addresses vif0 f0:ab:cd:ef:01:02])
AT_CHECK([ovn-sbctl chassis-add ch0 vxlan 1.2.3.5])
AT_CHECK([ovn-sbctl lport-bind vif0 ch0])

Expand All @@ -350,7 +350,7 @@ OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding | grep br-vtep_lswitch0`"
AT_CHECK([ovn-nbctl lswitch-add br-void])
# adds fake hv chassis 'ch1'.
AT_CHECK([ovn-nbctl lport-add br-void vif1])
AT_CHECK([ovn-nbctl lport-set-macs vif1 f0:ab:cd:ef:01:02])
AT_CHECK([ovn-nbctl lport-set-addresses vif1 f0:ab:cd:ef:01:02])
AT_CHECK([ovn-sbctl chassis-add ch1 vxlan 1.2.3.6])
AT_CHECK([ovn-sbctl lport-bind vif1 ch1])
OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding | grep vif1`"])
Expand All @@ -374,7 +374,7 @@ AT_CHECK([ovs-vsctl --columns=options list Interface bfd1.2.3.5 | cut -d ':' -f2
])

# adds another mac to lport.
AT_CHECK([ovn-nbctl lport-set-macs vif0 f0:ab:cd:ef:01:02 f0:ab:cd:ef:01:03])
AT_CHECK([ovn-nbctl lport-set-addresses vif0 f0:ab:cd:ef:01:02 f0:ab:cd:ef:01:03])
OVS_WAIT_UNTIL([test -n "`vtep-ctl list Ucast_Macs_Remote | grep 03`"])
AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -d ' ' | sort], [0], [dnl

Expand All @@ -383,15 +383,15 @@ AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -
])

# removes one mac to lport.
AT_CHECK([ovn-nbctl lport-set-macs vif0 f0:ab:cd:ef:01:03])
AT_CHECK([ovn-nbctl lport-set-addresses vif0 f0:ab:cd:ef:01:03])
OVS_WAIT_UNTIL([test -z "`vtep-ctl --columns=MAC list Ucast_Macs_Remote | grep 02`"])
AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -d ' ' | sort], [0], [dnl
"f0:ab:cd:ef:01:03"
])

# migrates mac to lport vif1 on 'br-void'.
AT_CHECK([ovn-nbctl lport-set-macs vif0])
AT_CHECK([ovn-nbctl lport-set-macs vif1 f0:ab:cd:ef:01:03])
AT_CHECK([ovn-nbctl lport-set-addresses vif0])
AT_CHECK([ovn-nbctl lport-set-addresses vif1 f0:ab:cd:ef:01:03])
OVS_WAIT_UNTIL([test -z "`vtep-ctl --columns=MAC list Ucast_Macs_Remote | grep 03`"])
AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -d ' ' | sort], [0], [dnl
])
Expand All @@ -407,13 +407,13 @@ OVN_CONTROLLER_VTEP_START
# creates a simple logical network with the vtep device and a fake hv chassis
# 'ch0'.
AT_CHECK([ovn-nbctl lport-add br-test vif0])
AT_CHECK([ovn-nbctl lport-set-macs vif0 f0:ab:cd:ef:01:02])
AT_CHECK([ovn-nbctl lport-set-addresses vif0 f0:ab:cd:ef:01:02])
AT_CHECK([ovn-sbctl chassis-add ch0 vxlan 1.2.3.5])
AT_CHECK([ovn-sbctl lport-bind vif0 ch0])

# creates another vif in the same logical switch with duplicate mac.
AT_CHECK([ovn-nbctl lport-add br-test vif1])
AT_CHECK([ovn-nbctl lport-set-macs vif1 f0:ab:cd:ef:01:02])
AT_CHECK([ovn-nbctl lport-set-addresses vif1 f0:ab:cd:ef:01:02])
AT_CHECK([ovn-sbctl lport-bind vif1 ch0])

# creates the logical switch in vtep and adds the corresponding logical
Expand Down Expand Up @@ -441,7 +441,7 @@ AT_CHECK([ovn-nbctl lport-del vif1])
AT_CHECK([ovn-nbctl lswitch-add br-void])
# adds fake hv chassis 'ch1' and vif1 with same mac address as vif0.
AT_CHECK([ovn-nbctl lport-add br-void vif1])
AT_CHECK([ovn-nbctl lport-set-macs vif1 f0:ab:cd:ef:01:02])
AT_CHECK([ovn-nbctl lport-set-addresses vif1 f0:ab:cd:ef:01:02])
AT_CHECK([ovn-sbctl chassis-add ch1 vxlan 1.2.3.6])
AT_CHECK([ovn-sbctl lport-bind vif1 ch1])
OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding | grep vif1`"])
Expand Down
14 changes: 7 additions & 7 deletions tests/ovn-nbctl.at
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,22 @@ AT_CLEANUP

dnl ---------------------------------------------------------------------

AT_SETUP([ovn-nbctl - macs])
AT_SETUP([ovn-nbctl - addresses])
OVN_NBCTL_TEST_START

AT_CHECK([ovn-nbctl lswitch-add ls0])
AT_CHECK([ovn-nbctl lport-add ls0 lp0])
AT_CHECK([ovn-nbctl lport-get-macs lp0], [0], [dnl
AT_CHECK([ovn-nbctl lport-get-addresses lp0], [0], [dnl
])

AT_CHECK([ovn-nbctl lport-set-macs lp0 00:11:22:33:44:55 unknown])
AT_CHECK([ovn-nbctl lport-get-macs lp0], [0], [dnl
AT_CHECK([ovn-nbctl lport-set-addresses lp0 00:11:22:33:44:55 unknown])
AT_CHECK([ovn-nbctl lport-get-addresses lp0], [0], [dnl
00:11:22:33:44:55
unknown
])

AT_CHECK([ovn-nbctl lport-set-macs lp0])
AT_CHECK([ovn-nbctl lport-get-macs lp0], [0], [dnl
AT_CHECK([ovn-nbctl lport-set-addresses lp0])
AT_CHECK([ovn-nbctl lport-get-addresses lp0], [0], [dnl
])

OVN_NBCTL_TEST_STOP
Expand All @@ -97,7 +97,7 @@ OVN_NBCTL_TEST_START

AT_CHECK([ovn-nbctl lswitch-add ls0])
AT_CHECK([ovn-nbctl lport-add ls0 lp0])
AT_CHECK([ovn-nbctl lport-get-macs lp0], [0], [dnl
AT_CHECK([ovn-nbctl lport-get-addresses lp0], [0], [dnl
])

AT_CHECK([ovn-nbctl lport-set-port-security lp0 aa:bb:cc:dd:ee:ff 00:11:22:33:44:55])
Expand Down
4 changes: 2 additions & 2 deletions tests/ovn-sbctl.at
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ OVN_SBCTL_TEST_START

AT_CHECK([ovn-nbctl lswitch-add br-test])
AT_CHECK([ovn-nbctl lport-add br-test vif0])
AT_CHECK([ovn-nbctl lport-set-macs vif0 f0:ab:cd:ef:01:02])
AT_CHECK([ovn-nbctl lport-set-addresses vif0 f0:ab:cd:ef:01:02])
AT_CHECK([ovn-sbctl chassis-add ch0 stt 1.2.3.5])
AT_CHECK([ovn-sbctl lport-bind vif0 ch0])

Expand All @@ -81,7 +81,7 @@ Chassis "ch0"

# adds another 'vif1'
AT_CHECK([ovn-nbctl lport-add br-test vif1])
AT_CHECK([ovn-nbctl lport-set-macs vif1 f0:ab:cd:ef:01:03])
AT_CHECK([ovn-nbctl lport-set-addresses vif1 f0:ab:cd:ef:01:03])
AT_CHECK([ovn-sbctl lport-bind vif1 ch0])

AT_CHECK([ovn-sbctl show | sed 's/vif[[0-9]]/vif/'], [0], [dnl
Expand Down
10 changes: 5 additions & 5 deletions tests/ovn.at
Original file line number Diff line number Diff line change
Expand Up @@ -534,9 +534,9 @@ for i in 1 2 3; do
ovs-vsctl add-port br-int vif$i$j -- set Interface vif$i$j external-ids:iface-id=lp$i$j options:tx_pcap=hv$i/vif$i$j-tx.pcap options:rxq_pcap=hv$i/vif$i$j-rx.pcap ofport-request=$i$j
ovn-nbctl lport-add lsw0 lp$i$j
if test $j = 1; then
ovn-nbctl lport-set-macs lp$i$j f0:00:00:00:00:$i$j unknown
ovn-nbctl lport-set-addresses lp$i$j f0:00:00:00:00:$i$j unknown
else
ovn-nbctl lport-set-macs lp$i$j f0:00:00:00:00:$i$j
ovn-nbctl lport-set-addresses lp$i$j f0:00:00:00:00:$i$j
ovn-nbctl lport-set-port-security lp$i$j f0:00:00:00:00:$i$j
fi
done
Expand Down Expand Up @@ -688,15 +688,15 @@ ovn_start
ovn-nbctl lswitch-add lsw0

ovn-nbctl lport-add lsw0 lp1
ovn-nbctl lport-set-macs lp1 f0:00:00:00:00:01
ovn-nbctl lport-set-addresses lp1 f0:00:00:00:00:01

ovn-nbctl lport-add lsw0 lp2
ovn-nbctl lport-set-macs lp2 f0:00:00:00:00:02
ovn-nbctl lport-set-addresses lp2 f0:00:00:00:00:02

ovn-nbctl lport-add lsw0 lp-vtep
ovn-nbctl lport-set-type lp-vtep vtep
ovn-nbctl lport-set-options lp-vtep vtep-physical-switch=br-vtep vtep-logical-switch=lsw0
ovn-nbctl lport-set-macs lp-vtep unknown
ovn-nbctl lport-set-addresses lp-vtep unknown

net_add n1 # Network to connect hv1, hv2, and vtep
net_add n2 # Network to connect vtep and hv3
Expand Down
Loading

0 comments on commit 2fa326a

Please sign in to comment.