bbf: Fix uci for proxy interface

Changes done are:
1. Interfaces in the proxy uci section are called upstream_interface
   and downstream_interface as against proxy_interface and snooping_interface
   earlier.
2. The interface now bears the value of the actual linux interface, so,
   the upstream interface for example is now eth4.1 instead of wan.
3. A bug in the determining of bridging instance was identified and fixed.

The UCI looks as follows now:
root@iopsys:~# cat /etc/config/mcast

config proxy 'mproxy_1'
	option enable '0'
	option proto 'igmp'
	option version '2'
	option robustness '2'
	option aggregation '0'
	option last_member_query_interval '10'
	option query_interval '120'
	option query_response_interval '10'
	list downstream_interface 'br-wan100'
	list upstream_interface 'eth4.1'

config snooping 'msnoop_1'
	option enable '0'
	option proto 'igmp'
	option version '2'
	option robustness '2'
	option aggregation '0'
	option interface 'br-wan100'
This commit is contained in:
Rahul 2020-04-13 08:39:15 +05:30
parent 1b16a14089
commit e6da2d7f4a
2 changed files with 82 additions and 46 deletions

View file

@ -587,7 +587,7 @@ static int get_igmp_snooping_interface_val(char *value, char *ifname, size_t s_i
/* Find out bridge section name using bridge key. */
struct uci_section *s = NULL;
char *sec_name;
uci_path_foreach_option_eq(bbfdm, "dmmap_network", "interface", "bridge_instance", key, s) {
uci_path_foreach_option_eq(bbfdm, "dmmap_network", "interface", "bridge_key", key, s) {
dmuci_get_value_by_section_string(s, "section_name", &sec_name);
break;
}
@ -674,10 +674,10 @@ static int del_igmpp_interface_obj(char *refparam, struct dmctx *ctx, void *data
if (found) {
if (strcmp(upstream, "1") == 0) {
dmuci_del_list_value_by_section((struct uci_section *)data,
"proxy_interface", if_name);
"upstream_interface", if_name);
} else {
dmuci_del_list_value_by_section((struct uci_section *)data,
"snooping_interface", if_name);
"downstream_interface", if_name);
}
break;
}
@ -692,10 +692,10 @@ static int del_igmpp_interface_obj(char *refparam, struct dmctx *ctx, void *data
if (if_name[0] != '\0') {
if (strcmp(upstream, "1") == 0) {
dmuci_del_list_value_by_section((struct uci_section *)data,
"proxy_interface", if_name);
"upstream_interface", if_name);
} else {
dmuci_del_list_value_by_section((struct uci_section *)data,
"snooping_interface", if_name);
"downstream_interface", if_name);
}
}
}
@ -1315,10 +1315,10 @@ static void update_proxy_interface_section(struct uci_section *s, char *section,
static int set_igmpp_interface_iface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *interface_linker = NULL;
char *linker, *interface_linker = NULL;
char ifname[16];
char *up, *f_inst;
struct uci_section *d_sec;
char *up, *f_inst, *if_type;
struct uci_section *d_sec, *s;
bool b;
switch (action) {
@ -1331,7 +1331,18 @@ static int set_igmpp_interface_iface(char *refparam, struct dmctx *ctx, void *da
if (get_igmp_snooping_interface_val(value, ifname, sizeof(ifname)) == 0) {
interface_linker = dmstrdup(ifname);
} else {
adm_entry_get_linker_value(ctx, value, &interface_linker);
adm_entry_get_linker_value(ctx, value, &linker);
uci_foreach_sections("network", "interface", s) {
if(strcmp(section_name(s), linker) != 0) {
continue;
}
dmuci_get_value_by_section_string(s, "type", &if_type);
if (strcmp(if_type, "bridge") == 0)
dmasprintf(&interface_linker, "br-%s", linker);
else
dmuci_get_value_by_section_string(s, "ifname", &interface_linker);
break;
}
}
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface",
"section_name", section_name((struct uci_section *)data), d_sec) {
@ -1341,11 +1352,11 @@ static int set_igmpp_interface_iface(char *refparam, struct dmctx *ctx, void *da
dmuci_get_value_by_section_string(d_sec, "upstream", &up);
string_to_bool(up, &b);
update_proxy_interface_section((struct uci_section *)data,
"snooping_interface", interface_linker, !b);
"downstream_interface", interface_linker, !b);
// Now update the proxy_interface list
update_proxy_interface_section((struct uci_section *)data,
"proxy_interface", interface_linker, b);
"upstream_interface", interface_linker, b);
break;
}
}
@ -1358,7 +1369,7 @@ static int set_igmpp_interface_iface(char *refparam, struct dmctx *ctx, void *da
static int get_igmpp_interface_iface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *d_sec;
struct uci_section *d_sec, *s;
char *ifname, *f_inst;
char sec_name[16];
int found = 0;
@ -1379,46 +1390,71 @@ static int get_igmpp_interface_iface(char *refparam, struct dmctx *ctx, void *da
}
// Check if this is bridge type interface
char val[16];
strncpy(val, ifname, sizeof(val));
if (strstr(ifname, "br-")) {
// Interface is bridge type, convert to network uci file section name
char val[16];
strncpy(val, ifname, sizeof(val));
char *tok, *end;
tok = strtok_r(val, "-", &end);
if (strcmp(tok, "br") == 0) {
strncpy(sec_name, end, sizeof(sec_name));
} else {
goto end;
}
char *tok, *end;
tok = strtok_r(val, "-", &end);
if ((tok == NULL) || (end == NULL)) {
// Not a bridge interface
adm_entry_get_linker_param(ctx, dm_print_path("%s%cIP%cInterface%c", dmroot, dm_delim,
dm_delim, dm_delim), ifname, value);
goto end;
}
char *proto;
uci_foreach_sections("network", "interface", s) {
if(strcmp(section_name(s), sec_name) != 0)
continue;
if (strcmp(tok, "br") == 0) {
strncpy(sec_name, end, sizeof(sec_name));
// In the dmmap_network file, the details related to the instance id etc. associated
// with this bridge is stored, we now switch our focus to it to extract the necessary
// information.
struct uci_section *dmmap_section, *port;
char *br_inst, *mg, linker[64] = "";
dmuci_get_value_by_section_string(s, "proto", &proto);
if (proto[0] != '\0') {
// It is a L3 bridge, get the linker accordingly
adm_entry_get_linker_param(ctx, dm_print_path("%s%cIP%cInterface%c",
dmroot, dm_delim, dm_delim, dm_delim), sec_name, value);
} else {
// It is a L2 bridge, get the linker accordingly
struct uci_section *dmmap_section, *port;
char *br_inst, *mg, linker[64] = "";
get_dmmap_section_of_config_section("dmmap_network", "interface", sec_name,
&dmmap_section);
if (dmmap_section != NULL) {
dmuci_get_value_by_section_string(dmmap_section, "bridge_instance", &br_inst);
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port",
"bridge_key", br_inst, port) {
dmuci_get_value_by_section_string(port, "mg_port", &mg);
if (strcmp(mg, "true") == 0)
snprintf(linker, sizeof(linker), "%s+", section_name(port));
else
continue;
get_dmmap_section_of_config_section("dmmap_network", "interface", sec_name,
&dmmap_section);
if (dmmap_section != NULL) {
dmuci_get_value_by_section_string(dmmap_section, "bridge_instance", &br_inst);
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port",
"bridge_port", "bridge_key", br_inst, port) {
dmuci_get_value_by_section_string(port, "mg_port", &mg);
if (strcmp(mg, "true") == 0)
snprintf(linker, sizeof(linker), "%s+", section_name(port));
else
continue;
adm_entry_get_linker_param(ctx, dm_print_path("%s%cBridging%cBridge%c", dmroot, dm_delim, dm_delim, dm_delim), linker, value);
adm_entry_get_linker_param(ctx, dm_print_path("%s%cBridging%cBridge%c", dmroot, dm_delim, dm_delim, dm_delim), linker, value);
break;
}
}
}
break;
}
} else {
char *device_name, *tmp_linker = NULL;
// it is a L3 interface, get the section name from device name to construct the linker
uci_foreach_sections("network", "interface", s) {
dmuci_get_value_by_section_string(s, "ifname", &device_name);
if (strcmp(device_name, ifname) == 0) {
tmp_linker = dmstrdup(section_name(s));
break;
}
}
if (tmp_linker == NULL) {
goto end;
}
adm_entry_get_linker_param(ctx, dm_print_path("%s%cIP%cInterface%c", dmroot, dm_delim,
dm_delim, dm_delim), tmp_linker, value);
}
end:
// Now, convert to linker.
if (*value == NULL)
*value = "";
@ -1445,11 +1481,11 @@ static int set_igmpp_interface_upstream(char *refparam, struct dmctx *ctx, void
dmuci_get_value_by_section_string(d_sec, "ifname", &ifname);
dmuci_set_value_by_section(d_sec, "upstream", (b) ? "1" : "0");
update_proxy_interface_section((struct uci_section *)data,
"snooping_interface", ifname, !b);
"downstream_interface", ifname, !b);
// Now update the proxy_interface list
update_proxy_interface_section((struct uci_section *)data,
"proxy_interface", ifname, b);
"upstream_interface", ifname, b);
break;
}
}

View file

@ -796,7 +796,7 @@ void synchronize_specific_config_sections_with_dmmap_mcast_iface(char *package,
// and update the dmmap section accordingly. The do the same exercise for the list
// snooping_interface
struct uci_list *proxy_iface = NULL;
dmuci_get_value_by_section_list(s, "proxy_interface", &proxy_iface);
dmuci_get_value_by_section_list(s, "upstream_interface", &proxy_iface);
if (proxy_iface != NULL) {
struct uci_element *e;
uci_foreach_element(proxy_iface, e) {
@ -827,7 +827,7 @@ void synchronize_specific_config_sections_with_dmmap_mcast_iface(char *package,
}
struct uci_list *snooping_iface = NULL;
dmuci_get_value_by_section_list(s, "snooping_interface", &snooping_iface);
dmuci_get_value_by_section_list(s, "downstream_interface", &snooping_iface);
if (snooping_iface != NULL) {
struct uci_element *e;
uci_foreach_element(snooping_iface, e) {