726eac0e10
- Small fixes from upstream OBS-URL: https://build.opensuse.org/package/show/network:fcoe/fcoe-utils?expand=0&rev=7
175 lines
4.8 KiB
Diff
175 lines
4.8 KiB
Diff
From 6bde8d1b9f63a7d110fab53e3791040cbe9b101f Mon Sep 17 00:00:00 2001
|
|
From: Hannes Reinecke <hare@suse.de>
|
|
Date: Tue, 19 Nov 2013 20:26:14 +0000
|
|
Subject: [PATCH 17/17] fipvlan: filter interfaces from rtnl_getlink
|
|
|
|
Instead of carrying around two different ways on selecting
|
|
interfaces we should be filter the list of possible interfaces
|
|
during RTM_GETLINK / RTM_NEWLINK and use only one list.
|
|
This safes us from having implement two codepaths for doing
|
|
the same thing.
|
|
|
|
Signed-off-by: Hannes Reinecke <hare@suse.de>
|
|
Signed-off-by: Robert Love <robert.w.love@intel.com>
|
|
---
|
|
fipvlan.c | 98 ++++++++++++++++++++++++++++-----------------------------------
|
|
1 file changed, 43 insertions(+), 55 deletions(-)
|
|
|
|
diff --git a/fipvlan.c b/fipvlan.c
|
|
index 5bedea1..1b8492d 100644
|
|
--- a/fipvlan.c
|
|
+++ b/fipvlan.c
|
|
@@ -447,6 +447,19 @@ static void rtnl_recv_newlink(struct nlmsghdr *nh)
|
|
memcpy(iff->mac_addr, RTA_DATA(ifla[IFLA_ADDRESS]), ETHER_ADDR_LEN);
|
|
strncpy(iff->ifname, RTA_DATA(ifla[IFLA_IFNAME]), IFNAMSIZ);
|
|
|
|
+ if (!config.automode) {
|
|
+ int i, iff_selected = 0;
|
|
+
|
|
+ for (i = 0; i < config.namec; i++) {
|
|
+ if (!strcmp(iff->ifname, config.namev[i]))
|
|
+ iff_selected = 1;
|
|
+ }
|
|
+ if (!iff_selected) {
|
|
+ FIP_LOG_DBG("ignoring if %s\n", iff->ifname);
|
|
+ free(iff);
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
if (ifla[IFLA_LINKINFO]) {
|
|
parse_linkinfo(linkinfo, ifla[IFLA_LINKINFO]);
|
|
/* Track VLAN devices separately */
|
|
@@ -836,22 +849,10 @@ static int probe_fip_interface(struct iff *iff)
|
|
static int send_vlan_requests(void)
|
|
{
|
|
struct iff *iff;
|
|
- int i;
|
|
int skipped = 0;
|
|
|
|
- if (config.automode) {
|
|
- TAILQ_FOREACH(iff, &interfaces, list_node) {
|
|
- skipped += probe_fip_interface(iff);
|
|
- }
|
|
- } else {
|
|
- for (i = 0; i < config.namec; i++) {
|
|
- iff = lookup_iff(0, config.namev[i]);
|
|
- if (!iff) {
|
|
- skipped++;
|
|
- continue;
|
|
- }
|
|
- skipped += probe_fip_interface(iff);
|
|
- }
|
|
+ TAILQ_FOREACH(iff, &interfaces, list_node) {
|
|
+ skipped += probe_fip_interface(iff);
|
|
}
|
|
return skipped;
|
|
}
|
|
@@ -865,7 +866,8 @@ static void do_vlan_discovery(void)
|
|
retry:
|
|
skipped += send_vlan_requests();
|
|
if (skipped && skip_retry_count++ < config.link_retry) {
|
|
- FIP_LOG_DBG("waiting for IFF_RUNNING [%d]\n", skip_retry_count);
|
|
+ FIP_LOG_DBG("waiting for IFF_RUNNING [%d/%d]\n",
|
|
+ skip_retry_count, config.link_retry);
|
|
recv_loop(500);
|
|
skipped = 0;
|
|
retry_count = 0;
|
|
@@ -873,6 +875,11 @@ retry:
|
|
}
|
|
recv_loop(200);
|
|
TAILQ_FOREACH(iff, &interfaces, list_node) {
|
|
+ if (!iff->fip_ready) {
|
|
+ FIP_LOG_DBG("if %d: skipping, FIP not ready\n",
|
|
+ iff->ifindex);
|
|
+ continue;
|
|
+ }
|
|
if (!iff->running && iff->linkup_sent) {
|
|
FIP_LOG_DBG("if %d: waiting for IFF_RUNNING [%d]\n",
|
|
iff->ifindex, retry_count);
|
|
@@ -911,47 +918,23 @@ retry:
|
|
static void cleanup_interfaces(void)
|
|
{
|
|
struct iff *iff;
|
|
- int i;
|
|
- int skipped = 0;
|
|
|
|
- if (config.automode) {
|
|
- TAILQ_FOREACH(iff, &interfaces, list_node) {
|
|
- if (iff->linkup_sent) {
|
|
- if (config.link_up && iff->resp_recv)
|
|
- continue;
|
|
- if (iff->fcoe_started)
|
|
- continue;
|
|
- if (TAILQ_EMPTY(&iff->vlans)) {
|
|
- FIP_LOG_DBG("shutdown if %d",
|
|
- iff->ifindex);
|
|
- rtnl_set_iff_down(iff->ifindex, NULL);
|
|
- iff->linkup_sent = false;
|
|
- }
|
|
- }
|
|
- }
|
|
- } else {
|
|
- for (i = 0; i < config.namec; i++) {
|
|
- iff = lookup_iff(0, config.namev[i]);
|
|
- if (!iff) {
|
|
- skipped++;
|
|
+ TAILQ_FOREACH(iff, &interfaces, list_node) {
|
|
+ if (iff->linkup_sent) {
|
|
+ if (config.link_up && iff->resp_recv)
|
|
continue;
|
|
- }
|
|
- if (iff->linkup_sent) {
|
|
- if (config.link_up && iff->resp_recv)
|
|
- continue;
|
|
- if (iff->fcoe_started)
|
|
- continue;
|
|
- if (TAILQ_EMPTY(&iff->vlans)) {
|
|
- FIP_LOG_DBG("shutdown if %d",
|
|
- iff->ifindex);
|
|
- rtnl_set_iff_down(iff->ifindex, NULL);
|
|
- iff->linkup_sent = false;
|
|
- }
|
|
+ if (iff->fcoe_started)
|
|
+ continue;
|
|
+ if (TAILQ_EMPTY(&iff->vlans)) {
|
|
+ FIP_LOG_DBG("shutdown if %d",
|
|
+ iff->ifindex);
|
|
+ rtnl_set_iff_down(iff->ifindex, NULL);
|
|
+ iff->linkup_sent = false;
|
|
}
|
|
}
|
|
}
|
|
-
|
|
}
|
|
+
|
|
/* this is to not require headers from libcap */
|
|
static inline int capget(cap_user_header_t hdrp, cap_user_data_t datap)
|
|
{
|
|
@@ -1003,13 +986,18 @@ int main(int argc, char **argv)
|
|
determine_libfcoe_interface();
|
|
|
|
find_interfaces(ns);
|
|
- while ((TAILQ_EMPTY(&interfaces)) && ++find_cnt < 5) {
|
|
- FIP_LOG_DBG("no interfaces found, trying again");
|
|
- find_interfaces(ns);
|
|
- }
|
|
+ if (config.automode)
|
|
+ while ((TAILQ_EMPTY(&interfaces)) && ++find_cnt < 5) {
|
|
+ FIP_LOG_DBG("no interfaces found, trying again");
|
|
+ find_interfaces(ns);
|
|
+ }
|
|
|
|
if (TAILQ_EMPTY(&interfaces)) {
|
|
- FIP_LOG_ERR(ENODEV, "no interfaces to perform discovery on");
|
|
+ if (config.automode)
|
|
+ FIP_LOG_ERR(ENODEV,
|
|
+ "no interfaces to perform discovery on");
|
|
+ else
|
|
+ FIP_LOG("no interfaces to perform discovery on");
|
|
exit(1);
|
|
}
|
|
|
|
--
|
|
1.8.1.4
|
|
|