[ovs-dev] [PATCH 2/2] bridge: reconfigure when system interfaces change

Ben Pfaff blp at nicira.com
Sun Aug 2 19:04:26 UTC 2015


On Fri, Jul 31, 2015 at 02:35:02PM -0300, Thadeu Lima de Souza Cascardo wrote:
> Whenever system interfaces are removed, added or change state, reconfigure
> bridge. This allows late interfaces to be added to the datapath when they are
> added to the system after ovs-vswitchd is started.
> 
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo at redhat.com>

Thanks.  This seems useful.  It might be too aggressive, but I'm willing
to take a "wait and see" attitude before making it more complicated.

I noticed that it doesn't immediately wake up if something changed
following bridge_run(), which seems entirely possible since there might
be more than one place that calls rtnetlink_run(), so just to be sure I
folded this in:

diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 625105b..f021360 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -3023,6 +3023,9 @@ bridge_wait(void)
     }
 
     if_notifier_wait();
+    if (ifaces_changed) {
+        poll_immediate_wake();
+    }
 
     sset_init(&types);
     ofproto_enumerate_types(&types);

I also folded in the following stylistic fixes, and applied the commit
to master.  Thank you!

diff --git a/lib/if-notifier-bsd.c b/lib/if-notifier-bsd.c
index a1c3d0e..b57b4b1 100644
--- a/lib/if-notifier-bsd.c
+++ b/lib/if-notifier-bsd.c
@@ -25,8 +25,8 @@ struct if_notifier {
     void *aux;
 };
 
-static void if_notifier_cb(const struct rtbsd_change *change OVS_UNUSED,
-                           void *aux)
+static void
+if_notifier_cb(const struct rtbsd_change *change OVS_UNUSED, void *aux)
 {
     struct if_notifier *notifier;
     notifier = aux;
@@ -50,7 +50,8 @@ if_notifier_create(if_notify_func *cb, void *aux)
     return notifier;
 }
 
-void if_notifier_destroy(struct if_notifier *notifier)
+void
+if_notifier_destroy(struct if_notifier *notifier)
 {
     if (notifier) {
         rtbsd_notifier_unregister(&notifier->notifier);
@@ -58,12 +59,14 @@ void if_notifier_destroy(struct if_notifier *notifier)
     }
 }
 
-void if_notifier_run(void)
+void
+if_notifier_run(void)
 {
     rtbsd_notifier_run();
 }
 
-void if_notifier_wait(void)
+void
+if_notifier_wait(void)
 {
     rtbsd_notifier_wait();
 }
diff --git a/lib/if-notifier-stub.c b/lib/if-notifier-stub.c
index ffd5876..a5b529a 100644
--- a/lib/if-notifier-stub.c
+++ b/lib/if-notifier-stub.c
@@ -25,14 +25,17 @@ if_notifier_create(if_notify_func *cb OVS_UNUSED, void *aux OVS_UNUSED)
     return NULL;
 }
 
-void if_notifier_destroy(struct if_notifier *notifier OVS_UNUSED)
+void
+if_notifier_destroy(struct if_notifier *notifier OVS_UNUSED)
 {
 }
 
-void if_notifier_run(void)
+void
+if_notifier_run(void)
 {
 }
 
-void if_notifier_wait(void)
+void
+if_notifier_wait(void)
 {
 }
diff --git a/lib/if-notifier.c b/lib/if-notifier.c
index 10cd292..9a64f9b 100644
--- a/lib/if-notifier.c
+++ b/lib/if-notifier.c
@@ -25,9 +25,8 @@ struct if_notifier {
     void *aux;
 };
 
-static
-void if_notifier_cb(const struct rtnetlink_change *change OVS_UNUSED,
-                           void *aux)
+static void
+if_notifier_cb(const struct rtnetlink_change *change OVS_UNUSED, void *aux)
 {
     struct if_notifier *notifier;
     notifier = aux;
@@ -45,7 +44,8 @@ if_notifier_create(if_notify_func *cb, void *aux)
     return notifier;
 }
 
-void if_notifier_destroy(struct if_notifier *notifier)
+void
+if_notifier_destroy(struct if_notifier *notifier)
 {
     if (notifier) {
         rtnetlink_notifier_destroy(notifier->notifier);
@@ -53,12 +53,14 @@ void if_notifier_destroy(struct if_notifier *notifier)
     }
 }
 
-void if_notifier_run(void)
+void
+if_notifier_run(void)
 {
     rtnetlink_run();
 }
 
-void if_notifier_wait(void)
+void
+if_notifier_wait(void)
 {
     rtnetlink_wait();
 }
diff --git a/lib/if-notifier.h b/lib/if-notifier.h
index 69ba08c..259138f 100644
--- a/lib/if-notifier.h
+++ b/lib/if-notifier.h
@@ -19,14 +19,12 @@
 
 struct if_notifier;
 
-typedef
-void if_notify_func(void *aux);
+typedef void if_notify_func(void *aux);
 
-struct if_notifier *
-if_notifier_create(if_notify_func *, void *aux);
+struct if_notifier *if_notifier_create(if_notify_func *, void *aux);
 void if_notifier_destroy(struct if_notifier *);
 
 void if_notifier_run(void);
 void if_notifier_wait(void);
 
-#endif
+#endif  /* if-notifier.h */



More information about the dev mailing list