diff options
author | Tonghao Zhang <xiangxia.m.yue@gmail.com> | 2018-02-04 06:45:38 -0800 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2018-02-05 09:39:03 -0800 |
commit | 91eb0b1aab2f0b4dccfccf11bfb955d2efa638be (patch) | |
tree | 37f0075b4a321ebe92f083a148cc557532c2545a | |
parent | 2b766a03f2516b6d950c3e71b52eab4c52840fa4 (diff) | |
download | openvswitch-91eb0b1aab2f0b4dccfccf11bfb955d2efa638be.tar.gz |
netdev-linux: Report netdev change events when mac changed.
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 <xiangxia.m.yue@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
-rw-r--r-- | lib/netdev-linux.c | 3 | ||||
-rw-r--r-- | lib/netlink-notifier.c | 4 | ||||
-rw-r--r-- | lib/netlink-notifier.h | 1 | ||||
-rw-r--r-- | lib/rtnetlink.c | 9 | ||||
-rw-r--r-- | lib/rtnetlink.h | 1 |
5 files changed, 15 insertions, 3 deletions
diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 6dae7964a..4e0473cf3 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -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; diff --git a/lib/netlink-notifier.c b/lib/netlink-notifier.c index 3acded418..7d8cfffa2 100644 --- a/lib/netlink-notifier.c +++ b/lib/netlink-notifier.c @@ -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. */ @@ -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; diff --git a/lib/netlink-notifier.h b/lib/netlink-notifier.h index f6a515039..dd0c183de 100644 --- a/lib/netlink-notifier.h +++ b/lib/netlink-notifier.h @@ -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 */ diff --git a/lib/rtnetlink.c b/lib/rtnetlink.c index 5009cd504..4d9003b52 100644 --- a/lib/rtnetlink.c +++ b/lib/rtnetlink.c @@ -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); + } +} diff --git a/lib/rtnetlink.h b/lib/rtnetlink.h index 91ed4860f..518320f73 100644 --- a/lib/rtnetlink.h +++ b/lib/rtnetlink.h @@ -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 */ |