Move from a custom-crafted singly-linked list to the SLIST_* macros
from queue(3). Improve vertical compactness by using a IGMP_PRINTF() macro rather than #ifdefing IGMP_DEBUG a large number of debugging printfs. Reviewed by: mdodd (SLIST changes)
This commit is contained in:
parent
a19f8dda70
commit
6c4b2ad305
@ -88,10 +88,16 @@ static int igmp_timers_are_running;
|
|||||||
static u_long igmp_all_hosts_group;
|
static u_long igmp_all_hosts_group;
|
||||||
static u_long igmp_all_rtrs_group;
|
static u_long igmp_all_rtrs_group;
|
||||||
static struct mbuf *router_alert;
|
static struct mbuf *router_alert;
|
||||||
static struct router_info *Head;
|
static SLIST_HEAD(, router_info) router_info_head;
|
||||||
|
|
||||||
static void igmp_sendpkt(struct in_multi *, int, unsigned long);
|
static void igmp_sendpkt(struct in_multi *, int, unsigned long);
|
||||||
|
|
||||||
|
#ifdef IGMP_DEBUG
|
||||||
|
#define IGMP_PRINTF(x) printf(x)
|
||||||
|
#else
|
||||||
|
#define IGMP_PRINTF(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
igmp_init()
|
igmp_init()
|
||||||
{
|
{
|
||||||
@ -117,36 +123,31 @@ igmp_init()
|
|||||||
ra->ipopt_list[3] = 0x00;
|
ra->ipopt_list[3] = 0x00;
|
||||||
router_alert->m_len = sizeof(ra->ipopt_dst) + ra->ipopt_list[1];
|
router_alert->m_len = sizeof(ra->ipopt_dst) + ra->ipopt_list[1];
|
||||||
|
|
||||||
Head = (struct router_info *) 0;
|
SLIST_INIT(&router_info_head);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct router_info *
|
static struct router_info *
|
||||||
find_rti(ifp)
|
find_rti(ifp)
|
||||||
struct ifnet *ifp;
|
struct ifnet *ifp;
|
||||||
{
|
{
|
||||||
register struct router_info *rti = Head;
|
struct router_info *rti;
|
||||||
|
|
||||||
#ifdef IGMP_DEBUG
|
rti = SLIST_FIRST(&router_info_head);
|
||||||
printf("[igmp.c, _find_rti] --> entering \n");
|
IGMP_PRINTF("[igmp.c, _find_rti] --> entering \n");
|
||||||
#endif
|
SLIST_FOREACH(rti, &router_info_head, rti_list) {
|
||||||
while (rti) {
|
if (rti->rti_ifp == ifp) {
|
||||||
if (rti->rti_ifp == ifp) {
|
IGMP_PRINTF(
|
||||||
#ifdef IGMP_DEBUG
|
"[igmp.c, _find_rti] --> found old entry \n");
|
||||||
printf("[igmp.c, _find_rti] --> found old entry \n");
|
|
||||||
#endif
|
|
||||||
return rti;
|
return rti;
|
||||||
}
|
}
|
||||||
rti = rti->rti_next;
|
|
||||||
}
|
}
|
||||||
MALLOC(rti, struct router_info *, sizeof *rti, M_IGMP, M_NOWAIT);
|
MALLOC(rti, struct router_info *, sizeof *rti, M_IGMP, M_NOWAIT);
|
||||||
rti->rti_ifp = ifp;
|
rti->rti_ifp = ifp;
|
||||||
rti->rti_type = IGMP_V2_ROUTER;
|
rti->rti_type = IGMP_V2_ROUTER;
|
||||||
rti->rti_time = 0;
|
rti->rti_time = 0;
|
||||||
rti->rti_next = Head;
|
SLIST_INSERT_HEAD(&router_info_head, rti, rti_list);
|
||||||
Head = rti;
|
|
||||||
#ifdef IGMP_DEBUG
|
IGMP_PRINTF("[igmp.c, _find_rti] --> created an entry \n");
|
||||||
printf("[igmp.c, _find_rti] --> created an entry \n");
|
|
||||||
#endif
|
|
||||||
return rti;
|
return rti;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,23 +413,18 @@ void
|
|||||||
igmp_slowtimo()
|
igmp_slowtimo()
|
||||||
{
|
{
|
||||||
int s = splnet();
|
int s = splnet();
|
||||||
register struct router_info *rti = Head;
|
struct router_info *rti;
|
||||||
|
|
||||||
#ifdef IGMP_DEBUG
|
IGMP_PRINTF("[igmp.c,_slowtimo] -- > entering \n");
|
||||||
printf("[igmp.c,_slowtimo] -- > entering \n");
|
SLIST_FOREACH(rti, &router_info_head, rti_list) {
|
||||||
#endif
|
|
||||||
while (rti) {
|
|
||||||
if (rti->rti_type == IGMP_V1_ROUTER) {
|
if (rti->rti_type == IGMP_V1_ROUTER) {
|
||||||
rti->rti_time++;
|
rti->rti_time++;
|
||||||
if (rti->rti_time >= IGMP_AGE_THRESHOLD) {
|
if (rti->rti_time >= IGMP_AGE_THRESHOLD) {
|
||||||
rti->rti_type = IGMP_V2_ROUTER;
|
rti->rti_type = IGMP_V2_ROUTER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rti = rti->rti_next;
|
|
||||||
}
|
}
|
||||||
#ifdef IGMP_DEBUG
|
IGMP_PRINTF("[igmp.c,_slowtimo] -- > exiting \n");
|
||||||
printf("[igmp.c,_slowtimo] -- > exiting \n");
|
|
||||||
#endif
|
|
||||||
splx(s);
|
splx(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ struct router_info {
|
|||||||
struct ifnet *rti_ifp;
|
struct ifnet *rti_ifp;
|
||||||
int rti_type; /* type of router which is querier on this interface */
|
int rti_type; /* type of router which is querier on this interface */
|
||||||
int rti_time; /* # of slow timeouts since last old query */
|
int rti_time; /* # of slow timeouts since last old query */
|
||||||
struct router_info *rti_next;
|
SLIST_ENTRY(router_info) rti_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user