if (!iface_minimal_checks(cfg, ifa))
continue;
- if ((hardware = lldpd_get_hardware(cfg, ifa->ifa_name, ð_ops)) == NULL) {
+ if ((hardware = lldpd_get_hardware(cfg,
+ ifa->ifa_name,
+ if_nametoindex(ifa->ifa_name),
+ ð_ops)) == NULL) {
if ((hardware = lldpd_alloc_hardware(cfg,
ifa->ifa_name)) == NULL) {
LLOG_WARNX("Unable to allocate space for %s",
continue;
}
hardware->h_ops = ð_ops;
+ hardware->h_ifindex = if_nametoindex(ifa->ifa_name);
TAILQ_INSERT_TAIL(&cfg->g_hardware, hardware, h_entries);
} else {
if (hardware->h_flags) continue; /* Already seen this time */
/* We received this on the physical interface. */
return n;
/* We received this on the bonding interface. Is it really for us? */
- if (from.sll_ifindex == if_nametoindex(hardware->h_ifname))
+ if (from.sll_ifindex == hardware->h_ifindex)
/* This is for us */
return n;
if (from.sll_ifindex == if_nametoindex((char*)hardware->h_data))
if ((master = iface_is_enslaved(cfg, ifa->ifa_name)) == -1)
continue;
- if ((hardware = lldpd_get_hardware(cfg, ifa->ifa_name, &bond_ops)) == NULL) {
+ if ((hardware = lldpd_get_hardware(cfg,
+ ifa->ifa_name,
+ if_nametoindex(ifa->ifa_name),
+ &bond_ops)) == NULL) {
if ((hardware = lldpd_alloc_hardware(cfg,
ifa->ifa_name)) == NULL) {
LLOG_WARNX("Unable to allocate space for %s",
continue;
}
hardware->h_ops = &bond_ops;
+ hardware->h_ifindex = if_nametoindex(ifa->ifa_name);
TAILQ_INSERT_TAIL(&cfg->g_hardware, hardware, h_entries);
} else {
if (hardware->h_flags) continue; /* Already seen this time */
3. we get a bridge
*/
if ((hardware = lldpd_get_hardware(cfg,
- ifv.u.device2, NULL)) == NULL) {
+ ifv.u.device2,
+ if_nametoindex(ifv.u.device2),
+ NULL)) == NULL) {
if (iface_is_bond(cfg, ifv.u.device2)) {
TAILQ_FOREACH(hardware, &cfg->g_hardware,
h_entries)
}
struct lldpd_hardware *
-lldpd_get_hardware(struct lldpd *cfg, char *name, struct lldpd_ops *ops)
+lldpd_get_hardware(struct lldpd *cfg, char *name, int index, struct lldpd_ops *ops)
{
struct lldpd_hardware *hardware;
TAILQ_FOREACH(hardware, &cfg->g_hardware, h_entries) {
if ((strcmp(hardware->h_ifname, name) == 0) &&
+ (hardware->h_ifindex == index) &&
((!ops) || (ops == hardware->h_ops)))
break;
}
int(*cleanup)(struct lldpd *, struct lldpd_hardware *); /* Cleanup function. */
};
+/* An interface is uniquely identified by h_ifindex, h_ifname and h_ops. This
+ * means if an interface becomes enslaved, it will be considered as a new
+ * interface. The same applies for renaming and we include the index in case of
+ * renaming to an existing interface. */
struct lldpd_hardware {
TAILQ_ENTRY(lldpd_hardware) h_entries;
#define MAX_HMSGSIZE 8192
/* lldpd.c */
-struct lldpd_hardware *lldpd_get_hardware(struct lldpd *, char *, struct lldpd_ops *);
+struct lldpd_hardware *lldpd_get_hardware(struct lldpd *,
+ char *, int, struct lldpd_ops *);
struct lldpd_hardware *lldpd_alloc_hardware(struct lldpd *, char *);
void lldpd_hardware_cleanup(struct lldpd*, struct lldpd_hardware *);
#ifdef ENABLE_DOT1