summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaul <paul>2003-06-06 23:24:55 +0000
committerpaul <paul>2003-06-06 23:24:55 +0000
commit592c8148981d196a7bda2f1b85a63943fd0cfdf2 (patch)
tree273fd4151921ffbb91cc42535083ff7e1bf04bdb
parentbf9392c6e932080156e70c0436977fd5dbcdb0cd (diff)
2003-06-07 Paul Jakma <paul@dishone.st>
* Revert Cougar's sort interface names patch, causes problems with enabling of interfaces for OSPF in ospfd.
-rw-r--r--ChangeLog5
-rw-r--r--lib/if.c69
-rw-r--r--lib/if.h2
-rw-r--r--lib/zclient.c5
-rw-r--r--ospfd/ospf_interface.c2
-rw-r--r--zebra/kernel_socket.c3
6 files changed, 19 insertions, 67 deletions
diff --git a/ChangeLog b/ChangeLog
index 7e0765c5..ecee45f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,3 @@
-2003-06-05 Hasso Tepper <hasso@linux.ee>
-
- * Patch from Cougar <cougar@random.ee>: Sort interface lists (iflist)
- by name.
-
2003-04-13 Paul Jakma <paul@dishone.st>
* Amir: Opaque LSA bug fix for deletion of Type11's
diff --git a/lib/if.c b/lib/if.c
index cb2d086e..f003754a 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -46,52 +46,6 @@ struct if_master
int (*if_delete_hook) (struct interface *);
} if_master;
-/* Compare interface names */
-int
-if_cmp_func (struct interface *ifp1, struct interface *ifp2)
-{
- unsigned int l1, l2;
- long int x1, x2;
- char *p1, *p2;
- int res;
-
- p1 = ifp1->name;
- p2 = ifp2->name;
-
- while (1) {
- /* look up to any number */
- l1 = strcspn(p1, "0123456789");
- l2 = strcspn(p2, "0123456789");
-
- /* name lengths are different -> compare names */
- if (l1 != l2)
- return (strcmp(p1, p2));
-
- res = strncmp(p1, p2, l1);
-
- /* names are different -> compare them */
- if (res)
- return res;
-
- /* with identical name part, go to numeric part */
-
- p1 += l1;
- p2 += l1;
-
- x1 = strtol(p1, &p1, 10);
- x2 = strtol(p2, &p2, 10);
-
- /* let's compare numbers now */
- if (x1 < x2)
- return -1;
- if (x1 > x2)
- return 1;
-
- /* numbers were equal, lets do it again..
- (it happens with name like "eth123.456:789") */
- }
-}
-
/* Create new interface structure. */
struct interface *
if_new ()
@@ -104,18 +58,13 @@ if_new ()
}
struct interface *
-if_create (char *name, int namelen)
+if_create ()
{
struct interface *ifp;
ifp = if_new ();
- if (name) {
- strncpy (ifp->name, name, namelen);
- listnode_add_sort (iflist, ifp);
- } else {
- listnode_add (iflist, ifp);
- }
+ listnode_add (iflist, ifp);
ifp->connected = list_new ();
ifp->connected->del = (void (*) (void *)) connected_free;
@@ -299,7 +248,10 @@ if_get_by_name (char *name)
ifp = if_lookup_by_name (name);
if (ifp == NULL)
- ifp = if_create (name, IFNAMSIZ);
+ {
+ ifp = if_create ();
+ strncpy (ifp->name, name, IFNAMSIZ);
+ }
return ifp;
}
@@ -478,7 +430,10 @@ DEFUN (interface,
ifp = if_lookup_by_name (argv[0]);
if (ifp == NULL)
- ifp = if_create (argv[0], INTERFACE_NAMSIZ);
+ {
+ ifp = if_create ();
+ strncpy (ifp->name, argv[0], INTERFACE_NAMSIZ);
+ }
vty->index = ifp;
vty->node = INTERFACE_NODE;
@@ -848,10 +803,8 @@ if_init ()
iflist = list_new ();
ifaddr_ipv4_table = route_table_init ();
- if (iflist) {
- iflist->cmp = (int (*)(void *, void *))if_cmp_func;
+ if (iflist)
return;
- }
memset (&if_master, 0, sizeof if_master);
}
diff --git a/lib/if.h b/lib/if.h
index c6469ea6..9ffe74cf 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -181,7 +181,7 @@ struct connected
/* Prototypes. */
struct interface *if_new (void);
-struct interface *if_create (char *name, int namelen);
+struct interface *if_create (void);
struct interface *if_lookup_by_index (unsigned int);
struct interface *if_lookup_by_name (char *);
struct interface *if_lookup_exact_address (struct in_addr);
diff --git a/lib/zclient.c b/lib/zclient.c
index f6be5138..bb7747fa 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -555,7 +555,10 @@ zebra_interface_add_read (struct stream *s)
/* If such interface does not exist, make new one. */
if (! ifp)
- ifp = if_create (ifname_tmp, IFNAMSIZ);
+ {
+ ifp = if_create ();
+ strncpy (ifp->name, ifname_tmp, IFNAMSIZ);
+ }
/* Read interface's index. */
ifp->ifindex = stream_getl (s);
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c
index d3ab01f5..08bc7fbe 100644
--- a/ospfd/ospf_interface.c
+++ b/ospfd/ospf_interface.c
@@ -745,7 +745,7 @@ ospf_vl_new (struct ospf *ospf, struct ospf_vl_data *vl_data)
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_vl_new(): creating pseudo zebra interface");
- vi = if_create (NULL, 0);
+ vi = if_create ();
co = connected_new ();
co->ifp = vi;
listnode_add (vi->connected, co);
diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c
index ccf8515f..30e0fb1d 100644
--- a/zebra/kernel_socket.c
+++ b/zebra/kernel_socket.c
@@ -218,8 +218,9 @@ ifm_read (struct if_msghdr *ifm)
return -1;
}
- ifp = if_create (sdl->sdl_data, sdl->sdl_nlen);
+ ifp = if_create ();
+ strncpy (ifp->name, sdl->sdl_data, sdl->sdl_nlen);
ifp->ifindex = ifm->ifm_index;
ifp->flags = ifm->ifm_flags;
#if defined(__bsdi__)