]> git.ipfire.org Git - people/ms/mstpd.git/commitdiff
Translate CIST flushing to the kernel bridge code
authorVitalii Demianets <vitas@nppfactor.kiev.ua>
Tue, 27 Sep 2011 13:55:22 +0000 (13:55 +0000)
committerVitalii Demianets <vitas@nppfactor.kiev.ua>
Tue, 27 Sep 2011 13:55:22 +0000 (13:55 +0000)
git-svn-id: http://svn.code.sf.net/p/mstpd/code/trunk@9 fbe50366-0c72-4402-a84b-5d246361dba7

bridge_track.c
driver.h
driver_deps.c

index ae22c6906ac70198c6771a98f5ac0869253f5eef..048a62ca5b22e97e608907b927d4f31c3ab4bbff 100644 (file)
@@ -25,6 +25,8 @@
 ******************************************************************************/
 
 #include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
 #include <linux/if_bridge.h>
 #include <asm/byteorder.h>
 
@@ -455,6 +457,18 @@ static int br_set_state(struct rtnl_handle *rth, unsigned ifindex, __u8 state)
     return rtnl_talk(rth, &req.n, 0, 0, NULL, NULL, NULL);
 }
 
+static int br_flush_port(char *ifname)
+{
+    char fname[128];
+    snprintf(fname, sizeof(fname), "/sys/class/net/%s/brport/flush", ifname);
+    int fd = open(fname, O_WRONLY);
+    TSTM(0 <= fd, -1, "Couldn't open flush file %s for write: %m", fname);
+    int write_result = write(fd, "1", 1);
+    close(fd);
+    TST(1 == write_result, -1);
+    return 0;
+}
+
 /* External actions for MSTP protocol */
 
 void MSTP_OUT_set_state(per_tree_port_t *ptp, int new_state)
@@ -508,11 +522,19 @@ void MSTP_OUT_set_state(per_tree_port_t *ptp, int new_state)
  */
 void MSTP_OUT_flush_all_fids(per_tree_port_t * ptp)
 {
-    /* TODO: do real flushing.
-     * Make it asynchronous, with completion function calling
-     * MSTP_IN_all_fids_flushed(ptp)
-     */
-    MSTP_IN_all_fids_flushed(ptp);
+    port_t *ifc = ptp->port;
+    bridge_t *br = ifc->bridge;
+
+    /* Translate CIST flushing to the kernel bridge code */
+    if(0 == ptp->MSTID)
+    { /* CIST */
+        if(0 > br_flush_port(ifc->sysdeps.name))
+            ERROR_PRTNAME(br, ifc,
+                          "Couldn't flush kernel bridge forwarding database");
+    }
+    /* Completion signal MSTP_IN_all_fids_flushed will be called by driver */
+    INFO_MSTINAME(br, ifc, ptp, "Flushing forwarding database");
+    driver_flush_all_fids(ptp);
 }
 
 /* ageingTime < 0 => command driver to use its internal setting */
index 07a5211a0472b6b74597d5edb930f25d1c0745e4..9fae78f91e5f249d814bcc5e888ac174e6b7e9e4 100644 (file)
--- a/driver.h
+++ b/driver.h
@@ -13,5 +13,6 @@
 #define _MSTP_DRIVER_H
 
 int driver_set_new_state(per_tree_port_t *ptp, int new_state);
+void driver_flush_all_fids(per_tree_port_t *ptp);
 
 #endif /* _MSTP_DRIVER_H */
index e979665ecc10667ed5321f8a269143b97b5086d2..102f7999c35f8e583cda50e1a554ca4b41426ff6 100644 (file)
@@ -26,3 +26,12 @@ int driver_set_new_state(per_tree_port_t *ptp, int new_state)
     /* TODO: insert driver-specific code here */
     return new_state;
 }
+
+void driver_flush_all_fids(per_tree_port_t *ptp)
+{
+    /* TODO: do real flushing.
+     * Make it asynchronous, with completion function calling
+     * MSTP_IN_all_fids_flushed(ptp)
+     */
+    MSTP_IN_all_fids_flushed(ptp);
+}