Patrick Lamaiziere wrote:
Hello,

freebsd 11.2/amd64 release
net-snmp-5.7.3_18

net-snmpd returns incomplete MAC addresses in IF-MIB::ifPhysAddress,
the first octet is always "0".

$ snmpwalk -v 2c -c "xxx" localhost 1.3.6.1.2.1.2.2.1.6
IF-MIB::ifPhysAddress.1 = STRING: 0:36:9f:93:7d:f8
IF-MIB::ifPhysAddress.2 = STRING: 0:36:9f:93:7d:fa
IF-MIB::ifPhysAddress.3 = STRING: 0:f4:bb:ef:c8:e4
...

$ ifconfig | grep ether
        ether a0:36:9f:93:7d:f8
        ether a0:36:9f:93:7d:fa
        ether ec:f4:bb:ef:c8:e4

tcpdump confirms that the problem is in net-snmpd (and not the client).

Also when using the MIB IP-MIB::ipNetToMediaPhysAddress the MAC
addresses are correct.

$ snmpwalk -v2c -c '***r***' localhost IP-MIB::ipNetToMediaPhysAddress | grep 
a0:36:9f:93:7d:f8
IP-MIB::ipNetToMediaPhysAddress.13.10.10.1.118 = STRING: a0:36:9f:93:7d:f8

I've checked net-snmpd 5.7.3 under linux and the mac addresses are
correct. (So it's specific to FreeBSD.)

Any clue ?

It looks like net-snmp being stupid, try the attached patch (put to files/).
--- agent/mibgroup/if-mib/data_access/interface_sysctl.c.orig   2018-10-05 
13:11:25 UTC
+++ agent/mibgroup/if-mib/data_access/interface_sysctl.c
@@ -397,7 +397,8 @@ netsnmp_arch_interface_container_load(netsnmp_containe
                 }
             }
             adl = (struct sockaddr_dl *) a;
-            if_name = (char *) adl->sdl_data;
+            if_name = malloc(adl->sdl_nlen + 1);
+            memcpy(if_name, adl->sdl_data, adl->sdl_nlen);
             if_name[adl->sdl_nlen] = '\0';
         }
         if (!(ifp->ifm_addrs & RTA_IFP) || if_name == NULL) {
@@ -411,6 +412,7 @@ netsnmp_arch_interface_container_load(netsnmp_containe
             netsnmp_access_interface_container_free(container,
                                                     
NETSNMP_ACCESS_INTERFACE_FREE_NOFLAGS);
             free(if_list);
+            free(if_name);
             return -3;
         }
 
@@ -429,6 +431,7 @@ netsnmp_arch_interface_container_load(netsnmp_containe
             entry->paddr_len = 6;
             memset(entry->paddr, 0, 6);
         }
+       free(if_name);
 
         entry->mtu = ifp->ifm_data.ifi_mtu;
         entry->type = ifp->ifm_data.ifi_type;
_______________________________________________
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"

Reply via email to