lldpad/lldpad-0.9.43-lldpad-use-is_valid_lldp_device-in-scan-path.patch
2011-09-08 08:34:30 +02:00

75 lines
1.9 KiB
Diff

From e126f697e635eb83410003e99c905ebd1788f149 Mon Sep 17 00:00:00 2001
From: John Fastabend <john.r.fastabend@intel.com>
Date: Wed, 27 Jul 2011 15:07:43 -0700
Subject: [PATCH 13/29] lldpad: use is_valid_lldp_device() in scan path
lldpad can miss netlink events when this occurs we do
an explicit scan of the ports and set them to the
correct state.
This replaces a series of if/else statements with
the is_valid_lldp_device() call.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
config.c | 40 ++++++++++++++++++++--------------------
1 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/config.c b/config.c
index a8ebe17..4c82bb6 100644
--- a/config.c
+++ b/config.c
@@ -346,28 +346,28 @@ void init_ports(void)
p = nameidx;
while (p->if_index != 0) {
- if (is_loopback(p->if_name)) {
- ;
- } else if (is_bond(p->if_name)) {
- if (add_bond_port(p->if_name) < 0)
- syslog(LOG_ERR, "failed to register port %s",
- p->if_name);
- } else if (is_vlan(p->if_name)) {
- ;
- } else if (is_macvtap(p->if_name)) {
- ;
- } else if (is_bridge(p->if_name)) {
- ; /* ignore bridge device */
- } else {
- add_port(p->if_name);
+ int valid = is_valid_lldp_device(p->if_name);
+ int err;
- if (check_link_status(p->if_name)) {
- LIST_FOREACH(np, &lldp_head, lldp) {
- if (np->ops->lldp_mod_ifup)
- np->ops->lldp_mod_ifup(p->if_name);
- }
- set_lldp_port_enable_state(p->if_name, 1);
+ if (!valid) {
+ p++;
+ continue;
+ }
+
+ if (is_bond(p->if_name))
+ err = add_bond_port(p->if_name);
+ else
+ err = add_port(p->if_name);
+
+ if (err) {
+ LLDPAD_ERR("%s: Error adding device %s\n",
+ __func__, p->if_name);
+ } else if (check_link_status(p->if_name)) {
+ LIST_FOREACH(np, &lldp_head, lldp) {
+ if (np->ops->lldp_mod_ifup)
+ np->ops->lldp_mod_ifup(p->if_name);
}
+ set_lldp_port_enable_state(p->if_name, 1);
}
p++;
}
--
1.7.6