Skip to content

Commit

Permalink
do timeout the MLD querier
Browse files Browse the repository at this point in the history
  • Loading branch information
jinmei committed Apr 30, 2000
1 parent 924ebb9 commit 0b3e0a4
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 20 deletions.
65 changes: 64 additions & 1 deletion kame/kame/pim6dd/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* Questions concerning this software should be directed to
* Pavlin Ivanov Radoslavov (pavlin@catarina.usc.edu)
*
* $Id: debug.c,v 1.5 2000/03/27 22:35:42 itojun Exp $
* $Id: debug.c,v 1.6 2000/04/30 10:50:31 jinmei Exp $
*/
/*
* Part of this program has been derived from mrouted.
Expand Down Expand Up @@ -66,6 +66,36 @@ unsigned long debug = 0x00000000; /* If (long) is smaller than
static char dumpfilename[] = _PATH_PIM6D_DUMP;
static char cachefilename[] = _PATH_PIM6D_CACHE; /* TODO: notused */

static char *
sec2str(total)
time_t total;
{
static char result[256];
int days, hours, mins, secs;
int first = 1;
char *p = result;

days = total / 3600 / 24;
hours = (total / 3600) % 24;
mins = (total / 60) % 60;
secs = total % 60;

if (days) {
first = 0;
p += sprintf(p, "%dd", days);
}
if (!first || hours) {
first = 0;
p += sprintf(p, "%dh", hours);
}
if (!first || mins) {
first = 0;
p += sprintf(p, "%dm", mins);
}
sprintf(p, "%ds", secs);

return(result);
}

char *
packet_kind(proto, type, code)
Expand Down Expand Up @@ -196,6 +226,7 @@ fdump(i)
fp = fopen(dumpfilename, "w");
if (fp != NULL) {
dump_vifs(fp);
dump_mldqueriers(fp);
dump_pim_mrt(fp);
dump_lcl_grp(fp);
(void) fclose(fp);
Expand Down Expand Up @@ -284,6 +315,8 @@ dump_vifs(fp)
fprintf(fp, " %-12s", "NO-NBR");
width += 6;
}
if (v->uv_flags & VIFF_QUERIER)
fprintf(fp, " QRY");

if ((n = v->uv_pim_neighbors) != NULL) {
/* Print the first neighbor on the same line */
Expand Down Expand Up @@ -384,6 +417,36 @@ log(severity, syserr, format, va_alist)
if (severity <= LOG_ERR) exit(-1);
}

void
dump_mldqueriers(fp)
FILE *fp;
{
struct uvif *v;
vifi_t vifi;
pim_nbr_entry_t *n;
time_t now;

fprintf(fp, "MLD Querier List\n");
fprintf(fp, " %-3s %6s %-40s %-5s %15s\n",
"Mif", "PhyIF", "Address", "Timer", "Last");
(void)time(&now);

for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
if (v->uv_querier) {
fprintf(fp, " %-3u %6s", vifi,
(v->uv_flags & MIFF_REGISTER) ? "regist":
v->uv_name);

fprintf(fp, " %-40s %5u %15s\n",
inet6_fmt(&v->uv_querier->al_addr.sin6_addr),
v->uv_querier->al_timer,
sec2str(now - v->uv_querier->al_ctime));
}
}

fprintf(fp, "\n");
}

/* TODO: format the output for better readability */
void
dump_pim_mrt(fp)
Expand Down
3 changes: 3 additions & 0 deletions kame/kame/pim6dd/mld6.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@
MLD6_QUERY_RESPONSE_INTERVAL / MLD6_TIMER_SCALE)
#define MLD6_LAST_LISTENER_QUERY_INTERVAL 1000 /* in milliseconds */
#define MLD6_LAST_LISTENER_QUERY_COUNT MLD6_ROBUSTNESS_VARIABLE
#define MLD6_OTHER_QUERIER_PRESENT_INTERVAL (MLD6_ROBUSTNESS_VARIABLE * \
MLD6_QUERY_INTERVAL + \
MLD6_QUERY_RESPONSE_INTERVAL / (2 * MLD6_TIMER_SCALE))
19 changes: 5 additions & 14 deletions kame/kame/pim6dd/mld6_proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
* Questions concerning this software should be directed to
* Kurt Windisch (kurtw@antc.uoregon.edu)
*
* $Id: mld6_proto.c,v 1.2 1999/09/12 17:00:09 jinmei Exp $
* $Id: mld6_proto.c,v 1.3 2000/04/30 10:50:31 jinmei Exp $
*/
/*
* Part of this program has been derived from PIM sparse-mode pimd.
Expand Down Expand Up @@ -176,19 +176,10 @@ accept_listener_query(src, dst, group, tmo)
if (!v->uv_querier) {
v->uv_querier = (struct listaddr *)
malloc(sizeof(struct listaddr));
v->uv_querier->al_next = (struct listaddr *)NULL;
v->uv_querier->al_timer = 0;
v->uv_querier->al_genid = 0;
v->uv_querier->al_pv = 0;
v->uv_querier->al_mv = 0;
v->uv_querier->al_old = 0;
v->uv_querier->al_index = 0;
v->uv_querier->al_timerid = 0;
v->uv_querier->al_query = 0;
v->uv_querier->al_flags = 0;

v->uv_flags &= ~VIFF_QUERIER;
memset(v->uv_querier, 0,
sizeof(struct listaddr));
}
v->uv_flags &= ~VIFF_QUERIER;
v->uv_querier->al_addr = *src;
time(&v->uv_querier->al_ctime);
}
Expand All @@ -198,7 +189,7 @@ accept_listener_query(src, dst, group, tmo)
* Reset the timer since we've received a query.
*/
if (v->uv_querier && inet6_equal(src, &v->uv_querier->al_addr))
v->uv_querier->al_timer = 0;
v->uv_querier->al_timer = MLD6_OTHER_QUERIER_PRESENT_INTERVAL;

/*
* If this is a Group-Specific query which we did not source,
Expand Down
4 changes: 1 addition & 3 deletions kame/kame/pim6dd/pim6_proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
* Questions concerning this software should be directed to
* Kurt Windisch (kurtw@antc.uoregon.edu)
*
* $Id: pim6_proto.c,v 1.4 1999/10/27 11:40:30 jinmei Exp $
* $Id: pim6_proto.c,v 1.5 2000/04/30 10:50:31 jinmei Exp $
*/
/*
* Part of this program has been derived from PIM sparse-mode pimd.
Expand Down Expand Up @@ -209,7 +209,6 @@ receive_pim6_hello(src, pim_message, datalen)
* DR address and it wins (is >) over the local address.
*/
v->uv_flags &= ~VIFF_DR;
v->uv_flags &= ~VIFF_QUERIER;
}

/*
Expand Down Expand Up @@ -285,7 +284,6 @@ delete_pim6_nbr(nbr_delete)
* DR address, but the local address is the winner.
*/
v->uv_flags |= VIFF_DR;
v->uv_flags |= VIFF_QUERIER;
}
}

Expand Down
16 changes: 15 additions & 1 deletion kame/kame/pim6dd/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* Questions concerning this software should be directed to
* Kurt Windisch (kurtw@antc.uoregon.edu)
*
* $Id: timer.c,v 1.3 1999/09/15 07:45:12 jinmei Exp $
* $Id: timer.c,v 1.4 2000/04/30 10:50:31 jinmei Exp $
*/
/*
* Part of this program has been derived from PIM sparse-mode pimd.
Expand Down Expand Up @@ -129,6 +129,20 @@ age_vifs()
for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
if (v->uv_flags & (VIFF_DISABLED | VIFF_DOWN))
continue;

/* Timeout the MLD querier (unless we re the querier) */
if ((v->uv_flags & VIFF_QUERIER) == 0 &&
v->uv_querier) { /* this must be non-NULL, but check for safety. */
IF_TIMEOUT(v->uv_querier->al_timer) {
/* act as a querier by myself */
v->uv_flags |= VIFF_QUERIER;
v->uv_querier->al_addr = v->uv_linklocal->pa_addr;
v->uv_querier->al_timer = MLD6_OTHER_QUERIER_PRESENT_INTERVAL;
time(&v->uv_querier->al_ctime); /* reset timestamp */
query_groups(v);
}
}

/* Timeout neighbors */
for (curr_nbr = v->uv_pim_neighbors; curr_nbr != NULL;
curr_nbr = next_nbr) {
Expand Down
5 changes: 4 additions & 1 deletion kame/kame/pim6dd/vif.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* Questions concerning this software should be directed to
* Pavlin Ivanov Radoslavov (pavlin@catarina.usc.edu)
*
* $Id: vif.c,v 1.3 1999/09/12 17:00:11 jinmei Exp $
* $Id: vif.c,v 1.4 2000/04/30 10:50:31 jinmei Exp $
*/
/*
* Part of this program has been derived from mrouted.
Expand Down Expand Up @@ -256,6 +256,9 @@ start_vif(vifi)
* query.
*/
v->uv_flags |= VIFF_QUERIER;
v->uv_querier->al_addr = v->uv_linklocal->pa_addr;
v->uv_querier->al_timer = MLD6_OTHER_QUERIER_PRESENT_INTERVAL;
time(&v->uv_querier->al_ctime); /* reset timestamp */
query_groups(v);

/*
Expand Down

0 comments on commit 0b3e0a4

Please sign in to comment.