Convert list of remote interfaces to LIST_* macros

This commit is contained in:
phk 2009-04-05 15:06:02 +00:00
parent ab2775f3db
commit bf0cde780f
3 changed files with 8 additions and 16 deletions

View File

@ -264,9 +264,9 @@ struct rt_entry {
*/
struct interface {
LIST_ENTRY(interface) int_list;
LIST_ENTRY(interface) remote_list;
struct interface *int_ahash, **int_ahash_prev;
struct interface *int_bhash, **int_bhash_prev;
struct interface *int_rlink, **int_rlink_prev;
struct interface *int_nhash, **int_nhash_prev;
char int_name[IF_NAME_LEN+1];
u_short int_index;
@ -486,7 +486,7 @@ extern naddr loopaddr; /* our address on loopback */
extern int tot_interfaces; /* # of remote and local interfaces */
extern int rip_interfaces; /* # of interfaces doing RIP */
extern struct ifhead ifnet; /* all interfaces */
extern struct interface *remote_if; /* remote interfaces */
extern struct ifhead remote_if; /* remote interfaces */
extern int have_ripv1_out; /* have a RIPv1 interface */
extern int have_ripv1_in;
extern int need_flash; /* flash update needed */

View File

@ -42,6 +42,7 @@ __RCSID("$Revision: 2.27 $");
#endif
struct ifhead ifnet = LIST_HEAD_INITIALIZER(ifnet); /* all interfaces */
struct ifhead remote_if = LIST_HEAD_INITIALIZER(ifnet); /* remote interfaces */
/* hash table for all interfaces, big enough to tolerate ridiculous
* numbers of IP aliases. Crazy numbers of aliases such as 7000
@ -56,7 +57,6 @@ struct interface *ahash_tbl[AHASH_LEN];
#define BHASH(a) &bhash_tbl[(a)%BHASH_LEN]
struct interface *bhash_tbl[BHASH_LEN];
struct interface *remote_if; /* remote interfaces */
/* hash for physical interface names.
* Assume there are never more 100 or 200 real interfaces, and that
@ -117,13 +117,8 @@ if_link(struct interface *ifp)
*hifp = ifp;
}
if (ifp->int_state & IS_REMOTE) {
ifp->int_rlink_prev = &remote_if;
ifp->int_rlink = remote_if;
if (remote_if != 0)
remote_if->int_rlink_prev = &ifp->int_rlink;
remote_if = ifp;
}
if (ifp->int_state & IS_REMOTE)
LIST_INSERT_HEAD(&remote_if, ifp, remote_list);
hifp = nhash(ifp->int_name);
if (ifp->int_state & IS_ALIAS) {
@ -467,11 +462,8 @@ ifdel(struct interface *ifp)
if (ifp->int_bhash != 0)
ifp->int_bhash->int_bhash_prev = ifp->int_bhash_prev;
}
if (ifp->int_state & IS_REMOTE) {
*ifp->int_rlink_prev = ifp->int_rlink;
if (ifp->int_rlink != 0)
ifp->int_rlink->int_rlink_prev = ifp->int_rlink_prev;
}
if (ifp->int_state & IS_REMOTE)
LIST_REMOVE(ifp, remote_list);
if (!(ifp->int_state & IS_ALIAS)) {
/* delete aliases when the main interface dies

View File

@ -96,7 +96,7 @@ read_rip(int sock,
cc+sizeof(inbuf.ifname));
/* check the remote interfaces first */
for (aifp = remote_if; aifp; aifp = aifp->int_rlink) {
LIST_FOREACH(aifp, &remote_if, remote_list) {
if (aifp->int_addr == from.sin_addr.s_addr)
break;
}