bbf: config vlan translation

add support to configure vlan translation via acs
This commit is contained in:
Rahul 2021-05-17 11:11:54 +05:30 committed by Amin Ben Ramdhane
parent 838372a16e
commit b05ef07c87
5 changed files with 75 additions and 1 deletions

View file

@ -9,7 +9,6 @@
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*
*/
#include "dmentry.h"
#include "bridging.h"
@ -2326,6 +2325,38 @@ void bridging_get_priority_list(char *uci_opt_name, void *data, char **value)
dmasprintf(value, "%s", uci_value);
}
void bridging_get_vlan_tvid(char *uci_opt_name, void *data, char **value)
{
dmuci_get_value_by_section_string(((struct bridge_vlan_args *)data)->bridge_vlan_sec, uci_opt_name, value);
}
void bridging_set_vlan_tvid(char *uci_opt_name, void *data, char *value)
{
char *ifname, *pch, *spch;
dmuci_get_value_by_section_string(((struct bridge_vlan_args *)data)->bridge_sec, "ifname", &ifname);
char *br_ifname = dmstrdup(ifname);
for (pch = strtok_r(br_ifname, " ", &spch); pch != NULL; pch = strtok_r(NULL, " ", &spch)) {
struct uci_section *device_s = NULL;
/* Update tvid in the device section */
uci_foreach_option_eq("network", "device", "name", pch, device_s) {
// tvid value 0 means vlan translation disable
if (strcmp(value, "0") == 0) {
dmuci_delete_by_section(device_s, uci_opt_name, NULL);
} else {
dmuci_set_value_by_section(device_s, uci_opt_name, value);
}
}
}
dmfree(br_ifname);
if (strcmp(value, "0") == 0) {
dmuci_delete_by_section(((struct bridge_vlan_args *)data)->bridge_vlan_sec, uci_opt_name, NULL);
} else {
dmuci_set_value_by_section(((struct bridge_vlan_args *)data)->bridge_vlan_sec, uci_opt_name, value);
}
}
void bridging_set_priority_list(char *uci_opt_name, void *data, char *value)
{
char buf[16];
@ -2892,6 +2923,19 @@ static int set_BridgingBridgeVLANPort_VLAN(char *refparam, struct dmctx *ctx, vo
dmuci_set_value_by_section(((struct bridge_vlanport_args *)data)->bridge_vlanport_sec, "vid", new_vid);
}
dmfree(new_vid);
/* Update tvid, read from dmmap_bridge_vlan, set in vlanport_sec */
struct uci_section *vlan_s = NULL;
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_vlan", "bridge_vlan", "br_inst", ((struct bridge_vlanport_args *)data)->br_inst, vlan_s) {
char *vlan_inst;
dmuci_get_value_by_section_string(vlan_s, "bridge_vlan_instance", &vlan_inst);
if (strcmp(vlan_inst, instance) == 0) {
char *tvid;
dmuci_get_value_by_section_string(vlan_s, "tvid", &tvid);
dmuci_set_value_by_section(((struct bridge_vlanport_args *)data)->bridge_vlanport_sec, "tvid", tvid);
break;
}
}
}
}
handle_inner_vid();

View file

@ -29,4 +29,6 @@ extern DMLEAF tBridgingProviderBridgeParams[];
void bridging_get_priority_list(char *uci_opt_name, void *data, char **value);
void bridging_set_priority_list(char *uci_opt_name, void *data, char *value);
void bridging_get_vlan_tvid(char *uci_opt_name, void *data, char **value);
void bridging_set_vlan_tvid(char *uci_opt_name, void *data, char *value);
#endif

View file

@ -54,6 +54,26 @@ static int set_BridgingBridgePort_DSCP_Eth_Priority_Map(char *refparam, struct d
return 0;
}
static int get_BridgingBridgeVLAN_TVID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
bridging_get_vlan_tvid("tvid", data, value);
return 0;
}
static int set_BridgingBridgeVLAN_TVID(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
if (dm_validate_int(value, RANGE_ARGS{{"0","4094"}}, 1))
return FAULT_9007;
return 0;
case VALUESET:
bridging_set_vlan_tvid("tvid", data, value);
return 0;
}
return 0;
}
/**********************************************************************************************************************************
* OBJ & PARAM DEFINITION
***********************************************************************************************************************************/
@ -63,3 +83,9 @@ DMLEAF tIOPSYS_BridgingBridgePortParams[] = {
{BBF_VENDOR_PREFIX"DSCPEthernetPriorityMapping", &DMWRITE, DMT_STRING, get_BridgingBridgePort_DSCP_Eth_Priority_Map, set_BridgingBridgePort_DSCP_Eth_Priority_Map, BBFDM_BOTH},
{0}
};
DMLEAF tIOPSYS_BridgingBridgeVLANParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{BBF_VENDOR_PREFIX"TVID", &DMWRITE, DMT_INT, get_BridgingBridgeVLAN_TVID, set_BridgingBridgeVLAN_TVID, BBFDM_BOTH},
{0}
};

View file

@ -15,5 +15,6 @@
#include <libbbf_api/dmcommon.h>
extern DMLEAF tIOPSYS_BridgingBridgePortParams[];
extern DMLEAF tIOPSYS_BridgingBridgeVLANParams[];
#endif //__IOPSYS_BRIDGING_H

View file

@ -26,5 +26,6 @@ DM_MAP_OBJ tVendorExtensionIOPSYS[] = {
{"Device.Time.", NULL, tIOPSYS_TimeParams},
{"Device.IEEE1905.AL.NetworkTopology.", tIOPSYS_IEEE1905ALNetworkTopologyObj, tIOPSYS_IEEE1905ALNetworkTopologyParams},
{"Device.Bridging.Bridge.{i}.Port.{i}.", NULL, tIOPSYS_BridgingBridgePortParams},
{"Device.Bridging.Bridge.{i}.VLAN.{i}.", NULL, tIOPSYS_BridgingBridgeVLANParams},
{0}
};