Commit f542031a authored by Juan Luis Manas's avatar Juan Luis Manas

userspace/wrsw_snmpd: fixed returned port number from ieee8021QBridgeTpFdbTable.

parent 1d2161e7
......@@ -607,11 +607,11 @@ static int fe_insert_static_entry(uint16_t vid,
// If an entry already exists in the fdb for the same mac and fid
// just register static entry in static_fdb list associated to it
// (if the static entry was only updated, it is already registered),
// and recalculate the forward vector combining static and dynamic info
// and recalculate the forward vector combining static and dynamic info
fe_register_static_entry(sfe, fe);
calculate_forward_vector(fe->static_fdb, &_port_map, &_use_dynamic);
ret = fe_update(fe, _port_map, ve->port_mask, _use_dynamic, STATIC);
fe->is_bpdu |= sfe->is_bpdu;
fe->is_bpdu |= sfe->is_bpdu;
} else {
// Create pure static entry
calculate_forward_vector(sfe, &_port_map, &_use_dynamic);
......@@ -619,7 +619,7 @@ static int fe_insert_static_entry(uint16_t vid,
_use_dynamic, STATIC);
if (ret == 0) {
fe_register_static_entry(sfe, fe);
fe->is_bpdu |= sfe->is_bpdu;
fe->is_bpdu |= sfe->is_bpdu;
}
}
return ret;
......@@ -913,13 +913,15 @@ int rtu_fdb_create_dynamic_entry(uint8_t mac[ETH_ALEN],
int rtu_fdb_read_entry(uint8_t mac[ETH_ALEN], // in
uint8_t fid, // in
uint32_t *port_map, // out
uint32_t *use_dynamic, // out
int *entry_type) // out
{
struct filtering_entry *fe;
lock();
if (rtu_sw_find_entry(mac, fid, &fe)) {
*port_map = fe->port_mask_dst;
*port_map = fe->port_mask_dst;
*use_dynamic = fe->use_dynamic;
*entry_type = fe->dynamic;
return unlock(0);
}
......@@ -934,6 +936,7 @@ int rtu_fdb_read_entry(uint8_t mac[ETH_ALEN], // in
int rtu_fdb_read_next_entry(uint8_t (*mac)[ETH_ALEN], // inout
uint8_t *fid, // inout
uint32_t *port_map, // out
uint32_t *use_dynamic, // out
int *entry_type) // out
{
struct filtering_entry *fe;
......@@ -950,11 +953,13 @@ int rtu_fdb_read_next_entry(uint8_t (*mac)[ETH_ALEN], // inout
// htab/hcam should be always consistent
mac_copy(*mac, fe->mac);
*fid = fe->fid;
*port_map = fe->port_mask_dst;
*port_map = fe->port_mask_dst;
*use_dynamic = fe->use_dynamic;
*entry_type = fe->dynamic;
return unlock(0);
}
void rtu_fdb_delete_dynamic_entries(int port, uint16_t vid)
{
if (illegal(port) || reserved(vid))
......
......@@ -56,6 +56,7 @@ int rtu_fdb_read_entry(
uint8_t mac[ETH_ALEN],
uint8_t fid,
uint32_t *port_map,
uint32_t *use_dynamic,
int *entry_type
) __attribute__((warn_unused_result));
......@@ -63,6 +64,7 @@ int rtu_fdb_read_next_entry(
uint8_t (*mac)[ETH_ALEN], // inout
uint8_t *fid, // inout
uint32_t *port_map, // out
uint32_t *use_dynamic, // out
int *entry_type // out
) __attribute__((warn_unused_result));
......
This diff is collapsed.
......@@ -56,6 +56,7 @@ int rtu_fdb_proxy_read_entry(
uint8_t mac[ETH_ALEN],
uint8_t fid,
uint32_t *port_map,
uint32_t *use_dynamic,
int *entry_type
) __attribute__((warn_unused_result));
......@@ -63,6 +64,7 @@ int rtu_fdb_proxy_read_next_entry(
uint8_t (*mac)[ETH_ALEN], // inout
uint8_t *fid, // inout
uint32_t *port_map, // out
uint32_t *use_dynamic, // out
int *entry_type // out
) __attribute__((warn_unused_result));
......
......@@ -138,6 +138,7 @@ static int rtu_fdb_srv_read_entry(
in->mac,
in->fid,
&out->port_map,
&out->use_dynamic,
&out->entry_type
);
......@@ -157,6 +158,7 @@ static int rtu_fdb_srv_read_next_entry(
&in->mac,
&in->fid,
&out->port_map,
&out->use_dynamic,
&out->entry_type
);
......
......@@ -93,6 +93,7 @@ struct rtu_fdb_read_entry_argdata {
struct rtu_fdb_read_entry_retdata {
int retval;
uint32_t port_map;
uint32_t use_dynamic;
int entry_type;
};
......@@ -107,6 +108,7 @@ struct rtu_fdb_read_next_entry_retdata {
uint8_t mac[ETH_ALEN];
uint8_t fid;
uint32_t port_map;
uint32_t use_dynamic;
int entry_type;
};
......
......@@ -51,16 +51,50 @@ struct mib_fdb_table_entry {
// Columns
uint32_t port_map;
uint32_t use_dynamic;
int type;
};
static int _log2(uint32_t val)
{
int ret = -1;
while (val >>= 1) ret++;
return ret;
}
static unsigned int port_no(struct mib_fdb_table_entry *ent)
{
int ret = -1;
uint32_t port_map_dyn, port_map_stc, port_map;
switch(ent->type) {
case STATIC:
return 0;
case DYNAMIC:
port_map = ent->port_map;
break;
case STATIC_DYNAMIC:
port_map_dyn = ent->port_map & ent->use_dynamic;
port_map_stc = ent->port_map & ~ent->use_dynamic;
port_map = port_map_dyn ? port_map_dyn:port_map_stc;
break;
}
while (port_map) {
ret++;
port_map >>= 1;
}
// TODO fix. port number 0 is reserved but RTU hardware uses it.
return (ret == -1) ? 0:ret;
}
static unsigned int entry_type(struct mib_fdb_table_entry *ent)
{
switch(ent->type) {
case STATIC:
return Mgmt;
case DYNAMIC:
return ent->port_map ? Learned:other;
case STATIC_DYNAMIC:
return (ent->port_map & ent->use_dynamic) ? Learned:Mgmt;
}
}
/**
* Get indexes for an entry.
......@@ -111,11 +145,10 @@ static int get_column(netsnmp_variable_list *vb,
{
switch (colnum) {
case COLUMN_PORT:
snmp_set_var_typed_integer(vb, ASN_UNSIGNED, _log2(ent->port_map));
snmp_set_var_typed_integer(vb, ASN_UNSIGNED, port_no(ent));
break;
case COLUMN_STATUS:
snmp_set_var_typed_integer(vb, ASN_INTEGER,
(ent->type == STATIC) ? Mgmt:Learned);
snmp_set_var_typed_integer(vb, ASN_INTEGER, entry_type(ent));
break;
default:
return SNMP_NOSUCHOBJECT;
......@@ -142,13 +175,14 @@ static int get(netsnmp_request_info *req, netsnmp_handler_registration *reginfo)
return SNMP_NOSUCHINSTANCE;
// Read entry from FDB.
err = rtu_fdb_proxy_read_entry(ent.mac, ent.fid, &ent.port_map, &ent.type);
err = rtu_fdb_proxy_read_entry(
ent.mac, ent.fid, &ent.port_map, &ent.use_dynamic, &ent.type);
if (errno)
goto minipc_err;
if (err)
goto entry_not_found;
return get_column(req->requestvb, tinfo->colnum, &ent);
return get_column(req->requestvb, tinfo->colnum, &ent);
entry_not_found:
DEBUGMSGTL((MIBMOD, "entry fid=%d mac=%s not found in fdb\n",
......@@ -190,9 +224,8 @@ static int get_next(netsnmp_request_info *req,
return SNMP_ENDOFMIBVIEW;
do {
err = rtu_fdb_proxy_read_next_entry(
&ent.mac, &ent.fid, &ent.port_map, &ent.type);
err = rtu_fdb_proxy_read_next_entry(
&ent.mac, &ent.fid, &ent.port_map, &ent.use_dynamic, &ent.type);
if (errno)
goto minipc_err;
if (err)
......
......@@ -51,6 +51,7 @@ struct mib_group_table_entry {
// Columns
uint32_t port_map;
uint32_t use_dynamic;
};
/**
......@@ -65,7 +66,7 @@ static int read_next_vid(uint16_t *vid)
uint32_t pm, us;
unsigned long ct;
err = rtu_fdb_proxy_read_vlan_entry(*vid, &fid, &t, &pm, &us, &ct);
if (errno)
goto minipc_err;
......@@ -110,7 +111,7 @@ static int read_next_entry(struct mib_group_table_entry *ent)
vid_a = ent->vid;
mac_copy(mac_a, ent->mac);
err = rtu_fdb_proxy_read_next_static_entry(&mac_a, &vid_a, &ep, &fp, &t, &s);
if (errno)
goto minipc_err;
......@@ -131,7 +132,7 @@ static int read_next_entry(struct mib_group_table_entry *ent)
vid_b = WILDCARD_VID;
mac_copy(mac_b, ent->mac);
err = rtu_fdb_proxy_read_next_static_entry(&mac_b, &vid_b, &ep, &fp, &t, &s);
if (errno)
goto minipc_err;
......@@ -274,15 +275,16 @@ static int get(netsnmp_request_info *req, netsnmp_handler_registration *reginfo)
// 802.1Q (12.7.7) When operating on a Dynamic Filtering Entry [...] the
// value used in the VID parameter can be any VID that has been allocated
// to the FID concerned)
err = rtu_fdb_proxy_read_vlan_entry(ent.vid, &fid, &t, &port_mask, &us, &ct);
if (errno)
goto minipc_err;
if (err)
goto vlan_not_found;
err = rtu_fdb_proxy_read_entry(ent.mac, fid, &ent.port_map, &t);
err = rtu_fdb_proxy_read_entry(
ent.mac, fid, &ent.port_map, &ent.use_dynamic, &t);
if (errno)
goto minipc_err;
if (err)
......@@ -334,15 +336,16 @@ static int get_next(netsnmp_request_info *req,
if (err)
return err;
// Obtain FID assigned to VID
err = rtu_fdb_proxy_read_vlan_entry(ent.vid, &fid, &t, &port_mask, &us, &ct);
if (errno)
goto minipc_err;
if (err)
goto vlan_not_found;
// Read entry from FDB
err = rtu_fdb_proxy_read_entry(ent.mac, fid, &ent.port_map, &t);
err = rtu_fdb_proxy_read_entry(
ent.mac, fid, &ent.port_map, &ent.use_dynamic, &t);
if (errno)
goto minipc_err;
if (err)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment