>Number:         171173
>Category:       bin
>Synopsis:       etherswitchcfg vlangroup IOETHERSWITCHGETPORT error
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug 29 20:20:01 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Harm Weites
>Release:        10.0-CURRENT
>Organization:
>Environment:
FreeBSD router1.weites.net 10.0-CURRENT FreeBSD 10.0-CURRENT #7 r239193M: Thu 
Jan  1 01:00:00 CET 1970     
root@dummy:/home/harm/work/freebsd/head/obj/mipseb/mips.mips/usr/home/harm/work/freebsd/head/src/sys/TP-WN1043ND
  mips
>Description:
I'm observing the following issue when using etherswitchcfg on my TP-Link 
1043ND embedded MIPS device. The default vlan configuration is done in the 
dev/etherswitchcfg init, creating vlan1 (wan port) and vlan2 (ports 1-4) with 
corresponding vlangroups. Those work as expected.

When configuring the switch to have a vlan(group) per physical port, I receive 
the following error:

etherswitchcfg: ioctl(IOETHERSWITCHGETPORT): Bad address

>How-To-Repeat:
# /sbin/etherswitchcfg port3 vlangroup 3
etherswitchcfg: ioctl(IOETHERSWITCHGETPORT): Bad address

>Fix:
While going through etherswitchcfg.c I noticed a subtle difference with 
set_port_vlangroup() and set_port_media(); the latter also uses 
ioctl(IOETHERSWITCHGETPORT) but does not fail and works just fine. 
It looks like there is a missing bzero() in set_port_vlangroup(), I've attached 
a patch to address that. While at it, I've also added a print to tell the user 
what'll happen, and a fix to prevent the function to segfault when a vlangroup 
is not supplied.

Result of my fixed code:

# ./etherswitchcfg port3 vlangroup 3
Set vlangroup of port 3 to 3
port3:
        vlangroup: 3
        media: Ethernet autoselect (100baseTX <full-duplex>)
        status: active



Patch attached with submission follows:

Index: etherswitchcfg.c
===================================================================
--- etherswitchcfg.c    (revision 239193)
+++ etherswitchcfg.c    (working copy)
@@ -136,13 +136,20 @@
        int v;
        etherswitch_port_t p;
        
+       if (!argv[1])
+               errx(EX_USAGE, "missing vlangroup #\n");
+
        v = strtol(argv[1], NULL, 0);
        if (v < 0 || v >= cfg->info.es_nvlangroups)
                errx(EX_USAGE, "vlangroup must be between 0 and %d", 
cfg->info.es_nvlangroups-1);
+
+       bzero(&p, sizeof(p));
        p.es_port = cfg->unit;
        if (ioctl(cfg->fd, IOETHERSWITCHGETPORT, &p) != 0)
                err(EX_OSERR, "ioctl(IOETHERSWITCHGETPORT)");
        p.es_vlangroup = v;
+
+       printf("Set vlangroup of port %d to %d\n", p.es_port, p.es_vlangroup);
        if (ioctl(cfg->fd, IOETHERSWITCHSETPORT, &p) != 0)
                err(EX_OSERR, "ioctl(IOETHERSWITCHSETPORT)");
 }


>Release-Note:
>Audit-Trail:
>Unformatted:
_______________________________________________
freebsd-bugs@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"

Reply via email to