summaryrefslogtreecommitdiffstats
path: root/lib/if.c
diff options
context:
space:
mode:
authorPaul Jakma <paul.jakma@sun.com>2006-10-16 01:33:50 +0200
committerPaul Jakma <paul.jakma@sun.com>2006-10-16 01:33:50 +0200
commit98954844ae56d142e96341d5dff959ec5518111e (patch)
tree8f411f4fec908605fb4e5ea423874c6a08d82b54 /lib/if.c
parent[snmp] Fix asn_build calls to pass correct variable sizes (fixes 64-bit issues) (diff)
downloadfrr-98954844ae56d142e96341d5dff959ec5518111e.tar.xz
frr-98954844ae56d142e96341d5dff959ec5518111e.zip
[lib] Handle upgrade from SUNWzebra to Quagga for 'interface fooX:Y' commands
2006-10-14 Paul Jakma <paul.jakma@sun.com> * if.c: (general) Handle upgrades from SUNWzebra, which tried to track each logical interface as a seperate struct interface, to Quagga, which assigns only one struct interface per ifindex. (if_sunwzebra_get) Try decompose a logical interface name (fooX:Y) to the 'primary' name (fooX), for Solaris. (interface_cmd) Use if_sunwzebra_get on Solaris.
Diffstat (limited to '')
-rw-r--r--lib/if.c48
1 files changed, 46 insertions, 2 deletions
diff --git a/lib/if.c b/lib/if.c
index c43d9564f..4493cc74b 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -501,9 +501,49 @@ DEFUN (no_interface_desc,
return CMD_SUCCESS;
}
+
+#ifdef SUNOS_5
+/* Need to handle upgrade from SUNWzebra to Quagga. SUNWzebra created
+ * a seperate struct interface for each logical interface, so config
+ * file may be full of 'interface fooX:Y'. Solaris however does not
+ * expose logical interfaces via PF_ROUTE, so trying to track logical
+ * interfaces can be fruitless, for that reason Quagga only tracks
+ * the primary IP interface.
+ *
+ * We try accomodate SUNWzebra by:
+ * - looking up the interface name, to see whether it exists, if so
+ * its useable
+ * - for protocol daemons, this could only because zebra told us of
+ * the interface
+ * - for zebra, only because it learnt from kernel
+ * - if not:
+ * - search the name to see if it contains a sub-ipif / logical interface
+ * seperator, the ':' char. If it does:
+ * - text up to that char must be the primary name - get that name.
+ * if not:
+ * - no idea, just get the name in its entirety.
+ */
+static struct interface *
+if_sunwzebra_get (const char *name, size_t nlen)
+{
+ struct interface *ifp;
+ size_t seppos = 0;
-
-/* See also wrapper function zebra_interface() in zebra/interface.c */
+ if ( (ifp = if_lookup_by_name_len(name, nlen)) != NULL)
+ return ifp;
+
+ /* hunt the primary interface name... */
+ while (seppos < nlen && name[seppos] != ':')
+ seppos++;
+
+ /* Wont catch seperator as last char, e.g. 'foo0:' but thats invalid */
+ if (seppos < nlen)
+ return if_get_by_name_len (name, seppos);
+ else
+ return if_get_by_name_len (name, nlen);
+}
+#endif /* SUNOS_5 */
+
DEFUN (interface,
interface_cmd,
"interface IFNAME",
@@ -521,7 +561,11 @@ DEFUN (interface,
return CMD_WARNING;
}
+#ifdef SUNOS_5
+ ifp = if_sunwzebra_get (argv[0], sl);
+#else
ifp = if_get_by_name_len(argv[0], sl);
+#endif /* SUNOS_5 */
vty->index = ifp;
vty->node = INTERFACE_NODE;