Skip to content

Commit

Permalink
netdev-linux: Report netdev change events when mac changed.
Browse files Browse the repository at this point in the history
When mac addr of ports on bridge has been changed, for example,

$ ip link set dev eth0 address 00:11:22:33:44:55

we should reconfigure the datapath id and mac addr of local port.
But now openvswitch dont do that as expected.

A simple example of how to reproduce it:

$ ovs-vsctl add-br br0
$ ifconfig br0 			# for example, mac is c6:c6:d7:46:b4:4b
$ ip link set dev br0 address 00:11:22:33:44:55
$ ifconfig br0 			# mac of br0 will be 00:11:22:33:44:55

then repeat:
$ ip link set dev br0 address 00:11:22:33:44:55
$ ifconfig br0 			# mac of br0 will be c6:c6:d7:46:b4:4b

This patch reports the mac changed event when ports changed, then
openvswitch will reconfigure the datapath id and mac addr of local
port.

Signed-off-by: Tonghao Zhang <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
xpu22 authored and blp committed Feb 5, 2018
1 parent 8e8b56d commit e8e1a40
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lib/netdev-linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,9 @@ netdev_linux_update(struct netdev_linux *dev,
dev->etheraddr = change->mac;
dev->cache_valid |= VALID_ETHERADDR;
dev->ether_addr_error = 0;

/* The mac addr has been changed, report it now. */
rtnetlink_report_link();
}

dev->ifindex = change->if_index;
Expand Down
4 changes: 1 addition & 3 deletions lib/netlink-notifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ VLOG_DEFINE_THIS_MODULE(netlink_notifier);

COVERAGE_DEFINE(nln_changed);

static void nln_report(const struct nln *nln, void *change, int group);

struct nln {
struct nl_sock *notify_sock; /* Netlink socket. */
struct ovs_list all_notifiers; /* All nln notifiers. */
Expand Down Expand Up @@ -225,7 +223,7 @@ nln_wait(struct nln *nln)
}
}

static void
void
nln_report(const struct nln *nln, void *change, int group)
{
struct nln_notifier *notifier;
Expand Down
1 change: 1 addition & 0 deletions lib/netlink-notifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ struct nln_notifier *nln_notifier_create(struct nln *, int multicast_group,
void nln_notifier_destroy(struct nln_notifier *);
void nln_run(struct nln *);
void nln_wait(struct nln *);
void nln_report(const struct nln *nln, void *change, int group);
#endif /* netlink-notifier.h */
9 changes: 9 additions & 0 deletions lib/rtnetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,12 @@ rtnetlink_wait(void)
nln_wait(nln);
}
}

/* Report RTNLGRP_LINK netdev change events. */
void
rtnetlink_report_link(void)
{
if (nln) {
nln_report(nln, NULL, RTNLGRP_LINK);
}
}
1 change: 1 addition & 0 deletions lib/rtnetlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@ rtnetlink_notifier_create(rtnetlink_notify_func *, void *aux);
void rtnetlink_notifier_destroy(struct nln_notifier *);
void rtnetlink_run(void);
void rtnetlink_wait(void);
void rtnetlink_report_link(void);
#endif /* rtnetlink.h */

0 comments on commit e8e1a40

Please sign in to comment.