From: Vitalii Demianets Date: Tue, 27 Sep 2011 13:55:22 +0000 (+0000) Subject: Translate CIST flushing to the kernel bridge code X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27ef19da22e1114714278e05c10da3d29ff3188e;p=people%2Fms%2Fmstpd.git Translate CIST flushing to the kernel bridge code git-svn-id: http://svn.code.sf.net/p/mstpd/code/trunk@9 fbe50366-0c72-4402-a84b-5d246361dba7 --- diff --git a/bridge_track.c b/bridge_track.c index ae22c69..048a62c 100644 --- a/bridge_track.c +++ b/bridge_track.c @@ -25,6 +25,8 @@ ******************************************************************************/ #include +#include +#include #include #include @@ -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 */ diff --git a/driver.h b/driver.h index 07a5211..9fae78f 100644 --- 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 */ diff --git a/driver_deps.c b/driver_deps.c index e979665..102f799 100644 --- a/driver_deps.c +++ b/driver_deps.c @@ -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); +}