Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions src/vde_switch/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ static int stdqlen=128;

static struct port **portv;

static int external_numports(void)
{
return (numports > 0) ? numports - 1 : 0;
}

#ifdef DEBUGOPT
#define DBGPORTNEW (dl)
#define DBGPORTDEL (dl+1)
Expand Down Expand Up @@ -730,7 +735,7 @@ void handle_in_packet(struct endpoint *ep, struct packet *packet, int len)

static int showinfo(FILE *fd)
{
printoutc(fd,"Numports=%d",numports);
printoutc(fd,"Numports=%d",external_numports());
printoutc(fd,"HUB=%s",(pflag & HUB_TAG)?"true":"false");
#ifdef PORTCOUNTERS
printoutc(fd,"counters=true");
Expand All @@ -748,50 +753,51 @@ static int portsetnumports(int val)
if(val > 0) {
/*resize structs*/
int i;
for(i=val;i<numports;i++)
int internal_numports = val + 1;
for(i=internal_numports;i<numports;i++)
if(portv[i] != NULL)
return EADDRINUSE;
portv=realloc(portv,val*sizeof(struct port *));
portv=realloc(portv,internal_numports*sizeof(struct port *));
Comment thread
danielinux marked this conversation as resolved.
Outdated
if (portv == NULL) {
printlog(LOG_ERR,"Numport resize failed portv %s",strerror(errno));
exit(1);
}
for (i=0;i<NUMOFVLAN;i++) {
if (vlant[i].table) {
vlant[i].table=ba_realloc(vlant[i].table,numports,val);
vlant[i].table=ba_realloc(vlant[i].table,numports,internal_numports);
if (vlant[i].table == NULL) {
printlog(LOG_ERR,"Numport resize failed vlan tables vlan table %s",strerror(errno));
exit(1);
}
}
if (vlant[i].bctag) {
vlant[i].bctag=ba_realloc(vlant[i].bctag,numports,val);
vlant[i].bctag=ba_realloc(vlant[i].bctag,numports,internal_numports);
if (vlant[i].bctag == NULL) {
printlog(LOG_ERR,"Numport resize failed vlan tables vlan bctag %s",strerror(errno));
exit(1);
}
}
if (vlant[i].bcuntag) {
vlant[i].bcuntag=ba_realloc(vlant[i].bcuntag,numports,val);
vlant[i].bcuntag=ba_realloc(vlant[i].bcuntag,numports,internal_numports);
if (vlant[i].bcuntag == NULL) {
printlog(LOG_ERR,"Numport resize failed vlan tables vlan bctag %s",strerror(errno));
exit(1);
}
}
if (vlant[i].notlearning) {
vlant[i].notlearning=ba_realloc(vlant[i].notlearning,numports,val);
vlant[i].notlearning=ba_realloc(vlant[i].notlearning,numports,internal_numports);
if (vlant[i].notlearning == NULL) {
printlog(LOG_ERR,"Numport resize failed vlan tables vlan notlearning %s",strerror(errno));
exit(1);
}
}
}
for (i=numports;i<val;i++)
for (i=numports;i<internal_numports;i++)
portv[i]=NULL;
#ifdef FSTP
fstsetnumports(val);
fstsetnumports(internal_numports);
#endif
numports=val;
numports=internal_numports;
return 0;
} else
return EINVAL;
Expand Down
4 changes: 2 additions & 2 deletions src/vde_switch/vde_switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,9 +601,9 @@ int main(int argc, char **argv)
atexit(cleanup);
hash_init(hash_size);
#ifdef FSTP
fst_init(numports);
fst_init(numports + 1);
#endif
port_init(numports);
port_init(numports + 1);
Comment thread
danielinux marked this conversation as resolved.
init_mods();
loadrcfile();
qtimer_init();
Expand Down
Loading