lldpd (0.9.5)
* Fix:
+ Compilation fix with older versions of GCC.
+ + Don't use ethtool at all to get real MAC address for enslaved
+ devices (always use /proc).
lldpd (0.9.4)
* Change:
return 0;
}
-/* Get the permanent MAC address using ethtool as a fallback There is a slight
- * difference with /proc/net/bonding method. The /proc/net/bonding method will
- * retrieve the MAC address of the interface before it was added to the
- * bond. The ethtool method will retrieve the real permanent MAC address. For
- * some devices, there is no such address (for example, virtual devices like
- * veth). */
-static void
-iflinux_get_permanent_mac_ethtool(struct lldpd *cfg,
- struct interfaces_device_list *interfaces,
- struct interfaces_device *iface)
-{
- struct interfaces_device *master;
- u_int8_t mac[ETHER_ADDR_LEN];
-
- /* We could do that for any interface, but let's do that only for
- * aggregates. */
- if ((master = iface->upper) == NULL || master->type != IFACE_BOND_T)
- return;
-
- log_debug("interfaces", "get MAC address for %s",
- iface->name);
-
- if (priv_iface_mac(iface->name, mac, ETHER_ADDR_LEN) != 0) {
- log_warnx("interfaces",
- "unable to get permanent MAC address for %s",
- master->name);
- return;
- }
- size_t i;
- for (i = 0; i < ETHER_ADDR_LEN; i++)
- if (mac[i] != 0) break;
- if (i == ETHER_ADDR_LEN) {
- log_warnx("interfaces",
- "no permanent MAC address found for %s",
- master->name);
- return;
- }
- memcpy(iface->address, mac,
- ETHER_ADDR_LEN);
-}
-
static void
iflinux_get_permanent_mac(struct lldpd *cfg,
struct interfaces_device_list *interfaces,
f = priv_open(path);
}
if (f < 0) {
- iflinux_get_permanent_mac_ethtool(cfg, interfaces, iface);
+ log_warnx("interfaces",
+ "unable to get permanent MAC address for %s",
+ master->name);
return;
}
if ((netbond = fdopen(f, "r")) == NULL) {
void asroot_open(void);
int priv_ethtool(char*, void*, size_t);
void asroot_ethtool(void);
-int priv_iface_mac(char*, void*, size_t);
-void asroot_iface_mac(void);
#endif
int priv_iface_init(int, char *);
int asroot_iface_init_os(int, char *, int *);
PRIV_IFACE_MULTICAST,
PRIV_IFACE_DESCRIPTION,
PRIV_IFACE_PROMISC,
- PRIV_IFACE_MAC,
PRIV_SNMP_SOCKET,
};
return rc;
}
-/* Proxy to get permanent MAC address. Not needed since
- * 75f3123c118743f52b690d9ab41649814befda0a (2.6.19). */
-int
-priv_iface_mac(char *ifname, void *mac, size_t length)
-{
- int rc, len;
- enum priv_cmd cmd = PRIV_IFACE_MAC;
- must_write(PRIV_UNPRIVILEGED, &cmd, sizeof(enum priv_cmd));
- len = strlen(ifname);
- must_write(PRIV_UNPRIVILEGED, &len, sizeof(int));
- must_write(PRIV_UNPRIVILEGED, ifname, len);
- priv_wait();
- must_read(PRIV_UNPRIVILEGED, &rc, sizeof(int));
- if (rc != 0)
- return rc;
- must_read(PRIV_UNPRIVILEGED, mac, length);
- return rc;
-}
-
void
asroot_open()
{
must_write(PRIV_PRIVILEGED, ðc, sizeof(struct ethtool_cmd));
}
-void
-asroot_iface_mac()
-{
- struct ifreq ifr = {};
- int len, rc, sock = -1;
- char *ifname;
- struct ethtool_perm_addr *epaddr;
-
- must_read(PRIV_PRIVILEGED, &len, sizeof(int));
- if ((ifname = (char*)malloc(len + 1)) == NULL)
- fatal("privsep", NULL);
- must_read(PRIV_PRIVILEGED, ifname, len);
- ifname[len] = '\0';
- strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
- free(ifname);
-
- if ((epaddr = malloc(sizeof(struct ethtool_perm_addr) + ETHER_ADDR_LEN)) == NULL)
- fatal("privsep", NULL);
- epaddr->cmd = ETHTOOL_GPERMADDR;
- epaddr->size = ETHER_ADDR_LEN;
- ifr.ifr_data = (caddr_t)epaddr;
- if (((rc = sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) ||
- (rc = ioctl(sock, SIOCETHTOOL, &ifr)) != 0) {
- if (sock != -1) close(sock);
- free(epaddr);
- must_write(PRIV_PRIVILEGED, &rc, sizeof(int));
- return;
- }
- close(sock);
- must_write(PRIV_PRIVILEGED, &rc, sizeof(int));
- must_write(PRIV_PRIVILEGED, epaddr->data, ETHER_ADDR_LEN);
- free(epaddr);
-}
-
int
asroot_iface_init_os(int ifindex, char *name, int *fd)
{
#ifdef HOST_OS_LINUX
{PRIV_OPEN, asroot_open},
{PRIV_ETHTOOL, asroot_ethtool},
- {PRIV_IFACE_MAC, asroot_iface_mac},
#endif
{PRIV_IFACE_INIT, asroot_iface_init},
{PRIV_IFACE_MULTICAST, asroot_iface_multicast},