summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarie Rannou2009-11-19 16:06:43 +0100
committerMarie Rannou2009-11-19 16:06:43 +0100
commit88234692f294cda177580e0d6e682f2d9f6322e4 (patch)
tree7d32b8aa03d84aef3480e880f8f00cf59a6710ff
parent172f114e498d300aa072dfd34e17d318f046c3b8 (diff)
[ndd] Changed config creator to match with new wanted working of IGMP snooping
-rw-r--r--application/ndd/src/config_creator.c56
1 files changed, 35 insertions, 21 deletions
diff --git a/application/ndd/src/config_creator.c b/application/ndd/src/config_creator.c
index bb15060986..649bc1eed3 100644
--- a/application/ndd/src/config_creator.c
+++ b/application/ndd/src/config_creator.c
@@ -40,7 +40,7 @@ extern int tag_vlan_one_port (spidlib_service_type_t* service_type, int* slave_i
extern int tag_vlan_several_ports(int* nb_ports, spidlib_service_type_t* service_type, int* slave_index, int* vid_tag) ;
extern int get_slave_config(char* mac, spidlib_service_type_t* service_type, int* slave_index);
extern int config_creator(char* mac_address, unsigned int * nb_eth_ports, unsigned int* architecture);
-extern int create_IGMP_snooping_file (char* mac);
+extern int create_IGMP_snooping_file (unsigned int slave_index);
//****************************************************************************************************************
@@ -972,32 +972,46 @@ Output: 0 - execution is correct
-1 - there are errors
Error handling: Only return value should be checked, errno is not used.
-----------------------------------------------------------------------------*/
-int create_IGMP_snooping_file(char* mac)
+int create_IGMP_snooping_file(unsigned int slave_index)
{
- int fd_exec_slave = -1, ret = -1;
+ int fd_exec_slave = -1, ret = -1, i= 0;
char temp[256];
- spidlib_igmp_entry_t igmp_entry;
-
- /* Copy mac address to retrieve it in igmp white list configuration file*/
- strcpy(igmp_entry.mcast_mac_address, mac);
-
- /* Get status of this slave concerning IGMP snooping*/
-// ret = spidlib_get_igmp_entry(&igmp_entry); //MRA
- if (ret != 0)
- return ret;
-
- /* In case of this slave is not allowed, launch rules to
- prevent from all multicast IGMP packets
+ spidlib_igmp_entry_t igmp_entry [SPIDLIB_WHITELIST_MAX_NB];
+ int nb_entries = SPIDLIB_WHITELIST_MAX_NB;
+
+ /* Launch rules to prevent from all multicast IGMP packets
Fill in 88slave */
if ((fd_exec_slave = open(SLAVE_FILE, O_WRONLY| O_CREAT | O_APPEND, 0777)) < 0)
return -1;
- if ( igmp_entry.enable == SPIDLIB_FALSE)
+ /* Build default rules for IGMP snooping : */
+ /* Default policy for IGMP table is DROP */
+ write(fd_exec_slave, "\n#IGMP Snooping",15);
+ memset(temp, 0, sizeof(temp));
+ sprintf(temp, "\nebtables -N IGMP\nebtables -P IGMP DROP\n");
+ write(fd_exec_slave, temp, strlen(temp));
+
+ /* Send all IGMP frames to IGMP chain*/
+ memset(temp, 0, sizeof(temp));
+ sprintf(temp, "ebtables -A FORWARD -p 0x0800 --ip-protocol 0x02 -j IGMP \nebtables -A FORWARD -p 0x8100 --vlan-encap 0x0800 --vlan-ip-protocol 0x02 -j IGMP\n");
+ write(fd_exec_slave, temp, strlen(temp));
+
+ /* Check if this slave is enable for igmp */
+ ret = spidlib_get_igmp_entry(igmp_entry, &nb_entries, slave_index);
+ if ((ret < 0) && (0 != nb_entries))
{
- write(fd_exec_slave, "\n#IGMP Snooping\n",17);
- memset(temp, 0, sizeof(temp));
- sprintf(temp, "ebtables -p 0x0800 --ip-protocol 0x02 -j DROP \nebtables -p 0x8100 --vlan-encap 0x0800 --vlan-ip-protocol 0x02 -j DROP\n");
- write(fd_exec_slave, temp, strlen(temp));
+ close (fd_exec_slave);
+ return -1;
+ }
+
+ for (i=0; i<nb_entries; i++)
+ {
+ if (SPIDLIB_TRUE == igmp_entry[i].enable)
+ {
+ memset(temp, 0, sizeof (temp));
+ sprintf(temp, "ebtables -A IGMP -d %s -j RETURN\n", igmp_entry[i].mcast_mac_address);
+ write(fd_exec_slave, temp, strlen(temp));
+ }
}
close (fd_exec_slave);
return 0;
@@ -1112,7 +1126,7 @@ int config_creator(char* mac_address, unsigned int * nb_eth_ports, unsigned int*
syslog(LOG_WARNING, "config_creator: couldn't create DBA PIR rules for slave %s\n", mac_address);
/*IGMP snooping management*/
- if (create_IGMP_snooping_file(mac_address) != 0)
+ if (create_IGMP_snooping_file(slave_index) != 0)
syslog(LOG_WARNING, "config_creator: couldn't create IGMP Snooping rules for slave %s\n", mac_address);