[-]
[+]
|
Changed |
pimd.spec
|
|
[-]
[+]
|
Changed |
pimd-2.1.8.tar.bz2/.gitignore
^
|
@@ -2,5 +2,9 @@
pimd
debian/files
pimd.map
+ChangeLog.*
*.o
.*.d
+*~
+\#*
+.\#*
|
[-]
[+]
|
Changed |
pimd-2.1.8.tar.bz2/ChangeLog
^
|
@@ -1,5 +1,27 @@
#+TITLE: pimd | Change Log
-#+AUTHOR: Ahmed Helmy, George Edmond Eddy, Pavlin Ivanov Radoslavov
+#+AUTHOR: Ahmed Helmy, George Edmond Eddy, Pavlin Ivanov Radoslavov
+
+* Version 2.1.8: October 22, 2011
+** Changes & New Features
+ - Update docs of static Rendez-Vous Point, rp_address, configuration in man page
+ and example pimd.conf. Thanks to Andriy Senkovych <andriysenkovych@gmail.com>
+ and YAMAMOTO Shigeru <shigeru@iij.ad.jp>
+
+ - Replaced malloc() with calloc() to mitigate risk of accessing junk data and ease
+ debugging. Thanks to YAMAMOTO Shigeru <shigeru@iij.ad.jp>
+
+ - Extend .conf file 'rp_address' option with 'priority' field. Code changes and
+ documentation updates by YAMAMOTO Shigeru <shigeru@iij.ad.jp>
+
+** Bug Fixes
+ - A serious bug in pim_proto.c:receive_pim_register() was found and fixed by
+ Jean-Pascal Billaud. In essence, the RP check was broken since the code only
+ looked at my_cand_rp_address, which is not set when using the rp_address config.
+ Everything works fine with auto-RP mode though. This issue completely breaks the
+ register path since the JOIN(S,G) is never sent back...
+
+ - Fix FTBFS issues reported from Debian. Later GCC versions trigger unused
+ variable warnings. Patches and cleanup Antonin Kral <a.kral@bobek.cz>
* Version 2.1.7: January 9, 2011
** Changes & New Features
|
[-]
[+]
|
Changed |
pimd-2.1.8.tar.bz2/Makefile
^
|
@@ -17,7 +17,7 @@
#
# VERSION ?= $(shell git tag -l | tail -1)
-VERSION ?= 2.1.7
+VERSION ?= 2.1.8
EXEC = pimd
CONFIG = $(EXEC).conf
PKG = $(EXEC)-$(VERSION)
@@ -40,7 +40,7 @@
IGMP_OBJS = igmp.o igmp_proto.o trace.o
ROUTER_OBJS = inet.o kern.o main.o config.o debug.o netlink.o routesock.o \
- vers.o callout.o ${RSRR_OBJS}
+ vers.o callout.o
PIM_OBJS = route.o vif.o timer.o mrt.o pim.o pim_proto.o rp.o
DVMRP_OBJS = dvmrp_proto.o
@@ -51,7 +51,7 @@
include snmp.mk
## Common
-CFLAGS = $(MCAST_INCLUDE) $(SNMPDEF) $(RSRRDEF) $(INCLUDES) $(DEFS) $(USERCOMPILE)
+CFLAGS += $(MCAST_INCLUDE) $(SNMPDEF) $(RSRRDEF) $(INCLUDES) $(DEFS) $(USERCOMPILE)
CFLAGS += -O2 -W -Wall -Werror -fno-strict-aliasing
#CFLAGS += -O -g
LDLIBS = $(SNMPLIBDIR) $(SNMPLIBS) $(EXTRA_LIBS)
|
[-]
[+]
|
Changed |
pimd-2.1.8.tar.bz2/callout.c
^
|
@@ -133,9 +133,9 @@
#endif
/* create a node */
- node = (struct timeout_q *)malloc(sizeof(struct timeout_q));
+ node = (struct timeout_q *)calloc(1, sizeof(struct timeout_q));
if (!node) {
- logit(LOG_ERR, 0, "Failed malloc() in timer_settimer\n");
+ logit(LOG_ERR, 0, "Failed calloc() in timer_settimer\n");
return -1;
}
node->func = action;
|
[-]
[+]
|
Changed |
pimd-2.1.8.tar.bz2/config.c
^
|
@@ -426,7 +426,7 @@
continue;
}
}
- ph = (struct phaddr *)malloc(sizeof(struct phaddr));
+ ph = (struct phaddr *)calloc(1, sizeof(struct phaddr));
if (ph == NULL)
return(FALSE);
if (altnet_masklen) {
@@ -473,7 +473,7 @@
}
}
- v_acl = (struct vif_acl *)malloc(sizeof(struct vif_acl));
+ v_acl = (struct vif_acl *)calloc(1, sizeof(struct vif_acl));
if (v_acl == NULL)
return(FALSE);
VAL_TO_MASK(v_acl->acl_mask, scoped_masklen);
@@ -767,7 +767,7 @@
* multicast group addresses as well.
*
* Format:
- * rp_address <rp-address>
+ * rp_address <rp-address> [<group-addr> [masklen <masklen>] [priority <number>]]
*
* Returns:
* When parsing @s is successful this function returns %TRUE, otherwise %FALSE.
@@ -776,10 +776,12 @@
{
char *w;
u_int32 local = 0xffffff;
- u_int32 group_addr;
- u_int32 masklen;
+ u_int32 group_addr = htonl(INADDR_UNSPEC_GROUP);
+ u_int32 masklen = PIM_GROUP_PREFIX_DEFAULT_MASKLEN;
+ u_int priority = PIM_DEFAULT_CAND_RP_PRIORITY;
struct rp_hold * rph;
+ /* next is RP addr */
w = next_word(&s);
if (EQUAL(w, "")) {
logit(LOG_WARNING, 0, "'rp_address' in %s: no <rp-addr> - ignoring", configfilename);
@@ -792,6 +794,7 @@
return FALSE;
}
+ /* next is group addr if exist */
w = next_word(&s);
if (!EQUAL(w, "")) {
group_addr = inet_parse(w, 4);
@@ -800,27 +803,50 @@
return FALSE;
}
- if (EQUAL((w = next_word(&s)), "masklen")) {
- w = next_word(&s);
- if (sscanf(w, "%u", &masklen) == 1) {
- if (masklen > (sizeof(group_addr) * 8))
- masklen = (sizeof(group_addr) * 8);
- else if (masklen < 4)
- masklen = 4;
- }
- else
- masklen = PIM_GROUP_PREFIX_DEFAULT_MASKLEN;
- }
- else
- masklen = PIM_GROUP_PREFIX_DEFAULT_MASKLEN;
+ masklen = PIM_GROUP_PREFIX_DEFAULT_MASKLEN;
+ priority = PIM_DEFAULT_CAND_RP_PRIORITY;
+
+ /* next is prefix or priority if exist */
+ while (!EQUAL((w = next_word(&s)), "")) {
+ if (EQUAL(w, "masklen")) {
+ w = next_word(&s);
+ if (sscanf(w, "%u", &masklen) == 1) {
+ if (masklen > (sizeof(group_addr) * 8)) {
+ masklen = (sizeof(group_addr) * 8);
+ }
+ else if (masklen < PIM_GROUP_PREFIX_MIN_MASKLEN) {
+ logit(LOG_WARNING, 0, "'rp_address' in %s: %s is too small. set to %d.", configfilename, w, PIM_GROUP_PREFIX_MIN_MASKLEN);
+ masklen = PIM_GROUP_PREFIX_MIN_MASKLEN;
+ }
+ }
+ else {
+ logit(LOG_WARNING, 0, "'rp_address' in %s: %s is invalid masklen. set to default(%d)", configfilename, w, PIM_GROUP_PREFIX_DEFAULT_MASKLEN);
+ masklen = PIM_GROUP_PREFIX_DEFAULT_MASKLEN;
+ }
+ }
+ else if (EQUAL(w, "priority")) {
+ w = next_word(&s);
+ if (sscanf(w, "%u", &priority) == 1) {
+ if (priority > PIM_MAX_CAND_RP_PRIORITY) {
+ logit(LOG_WARNING, 0, "'rp_address' in %s: %s is too big. set to %d.", configfilename, w, PIM_MAX_CAND_RP_PRIORITY);
+ priority = PIM_MAX_CAND_RP_PRIORITY;
+ }
+ }
+ else {
+ logit(LOG_WARNING, 0, "'rp_address' in %s: %s is invalid priority. set to default(%d)", configfilename, w, PIM_DEFAULT_CAND_RP_PRIORITY);
+ priority = PIM_DEFAULT_CAND_RP_PRIORITY;
+ }
+ }
+ }
}
else {
- group_addr = htonl(224 << 24);
- masklen = 4;
+ group_addr = htonl(INADDR_UNSPEC_GROUP);
+ masklen = PIM_GROUP_PREFIX_MIN_MASKLEN;
+ priority = 1;
}
/* save */
- rph = malloc(sizeof(*rph));
+ rph = calloc(1, sizeof(*rph));
if (!rph) {
logit(LOG_WARNING, 0, "Ran out of memory in parse_rp_address()");
return FALSE;
@@ -828,12 +854,13 @@
rph->address = local;
rph->group = group_addr;
VAL_TO_MASK(rph->mask, masklen);
+ rph->priority = priority;
/* attach at the beginning */
rph->next = g_rp_hold;
g_rp_hold = rph;
- logit(LOG_INFO, 0, "Added static RP: %s, group %s/%d", inet_fmt(local, s1, sizeof(s1)), inet_fmt(group_addr, s2, sizeof(s2)), masklen);
+ logit(LOG_INFO, 0, "Added static RP: %s, group %s/%d, prioriy %d", inet_fmt(local, s1, sizeof(s1)), inet_fmt(group_addr, s2, sizeof(s2)), masklen, priority);
return TRUE;
}
@@ -1079,7 +1106,7 @@
/* TODO: HARDCODING!!! */
cand_rp_adv_message.buffer =
- (u_int8 *)malloc(4 + sizeof(pim_encod_uni_addr_t)
+ (u_int8 *)calloc(1, 4 + sizeof(pim_encod_uni_addr_t)
+ 255 * sizeof(pim_encod_grp_addr_t));
if (!cand_rp_adv_message.buffer) {
logit(LOG_ERR, errno, "Ran out of memory in config_vifs_from_file()");
|
[-]
[+]
|
Changed |
pimd-2.1.8.tar.bz2/debian/changelog
^
|
@@ -1,3 +1,9 @@
+pimd (2.1.7-1) unstable; urgency=low
+
+ * New upstream
+
+ -- Antonin Kral <A.Kral@sh.cvut.cz> Mon, 05 Sep 2011 11:54:53 +0200
+
pimd (2.1.6-1) unstable; urgency=low
* New upstream version changing location of dump file(s) to
@@ -14,7 +20,7 @@
pimd (2.1.5-3) unstable; urgency=low
- * fix for regression of unused parameter on *bsd,
+ * fix for regression of unused parameter on *bsd,
Closes: Bug#608711 (commit 6eaff4dc495ff67933a4)
* add -Werror to debian/rules
|
[-]
[+]
|
Changed |
pimd-2.1.8.tar.bz2/defs.h
^
|
@@ -628,6 +628,7 @@
u_int32 address;
u_int32 group;
u_int32 mask;
+ u_int8 priority;
};
#ifndef HAVE_STRLCPY
|
[-]
[+]
|
Changed |
pimd-2.1.8.tar.bz2/igmp.c
^
|
@@ -70,8 +70,8 @@
{
struct ip *ip;
- igmp_recv_buf = malloc(RECV_BUF_SIZE);
- igmp_send_buf = malloc(SEND_BUF_SIZE);
+ igmp_recv_buf = calloc(1, RECV_BUF_SIZE);
+ igmp_send_buf = calloc(1, SEND_BUF_SIZE);
if (!igmp_recv_buf || !igmp_send_buf)
logit(LOG_ERR, 0, "Ran out of memory in init_igmp()");
|
[-]
[+]
|
Changed |
pimd-2.1.8.tar.bz2/igmp_proto.c
^
|
@@ -148,9 +148,9 @@
inet_fmt(v->uv_querier->al_addr, s2, sizeof(s2)) :
"me", vifi);
if (!v->uv_querier) {
- v->uv_querier = (struct listaddr *) malloc(sizeof(struct listaddr));
+ v->uv_querier = (struct listaddr *) calloc(1, sizeof(struct listaddr));
if (!v->uv_querier) {
- logit(LOG_ERR, 0, "Failed malloc() in accept_membership_query()\n");
+ logit(LOG_ERR, 0, "Failed calloc() in accept_membership_query()\n");
return;
}
@@ -264,7 +264,7 @@
* If not found, add it to the list and update kernel cache.
*/
if (g == NULL) {
- g = (struct listaddr *)malloc(sizeof(struct listaddr));
+ g = (struct listaddr *)calloc(1, sizeof(struct listaddr));
if (!g) {
logit(LOG_ERR, 0, "Ran out of memory"); /* fatal */
return;
@@ -409,9 +409,9 @@
{
cbk_t *cbk;
- cbk = (cbk_t *) malloc(sizeof(cbk_t));
+ cbk = (cbk_t *) calloc(1, sizeof(cbk_t));
if (!cbk) {
- logit(LOG_ERR, 0, "Failed malloc() in SetTimer()\n");
+ logit(LOG_ERR, 0, "Failed calloc() in SetTimer()\n");
return -1;
}
@@ -458,9 +458,9 @@
{
cbk_t *cbk;
- cbk = (cbk_t *)malloc(sizeof(cbk_t));
+ cbk = (cbk_t *)calloc(1, sizeof(cbk_t));
if (!cbk) {
- logit(LOG_ERR, 0, "Failed malloc() in SetQueryTimer()\n");
+ logit(LOG_ERR, 0, "Failed calloc() in SetQueryTimer()\n");
return -1;
}
|
[-]
[+]
|
Changed |
pimd-2.1.8.tar.bz2/main.c
^
|
@@ -167,10 +167,10 @@
{
if (nhandlers >= NHANDLERS)
return -1;
-
+
ihandlers[nhandlers].fd = fd;
ihandlers[nhandlers++].func = func;
-
+
return 0;
}
@@ -238,11 +238,11 @@
remove(file);
kill(pid, signo);
if (file) {
- int result;
-
usleep(200);
snprintf(buf, sizeof(buf), "cat %s", file);
- result = system(buf);
+ if (-1 == system(buf)) {
+ warnx("Failed listing file %s\n", file);
+ }
}
}
}
@@ -287,8 +287,8 @@
}
int main(int argc, char *argv[])
-{
- int dummy, dummysigalrm, foreground = 0;
+{
+ int dummysigalrm, foreground = 0;
struct timeval tv, difftime, curtime, lasttime, *timeout;
fd_set rfds, readers;
int nfds, n, i, secs, ch;
@@ -308,7 +308,7 @@
/* {"show-debug", 0, 0, 'p'}, */
{0, 0, 0, 0}
};
-
+
snprintf(versionstring, sizeof (versionstring), "pimd version %s", todaysversion);
while ((ch = getopt_long (argc, argv, "c:d::fhlNP::vqr", long_options, NULL)) != EOF) {
@@ -430,7 +430,7 @@
}
fprintf(stderr, ")\n");
}
-
+
/*
* Create directory for runtime files
*/
@@ -450,7 +450,7 @@
do_randomize();
time(&boottime);
-
+
/* Start up the log rate-limiter */
resetlogging(NULL);
@@ -462,20 +462,20 @@
#endif /* HAVE_ROUTING_SOCKETS */
init_pim_mrt();
init_timers();
-
+
/* TODO: check the kernel DVMRP/MROUTED/PIM support version */
-
+
#ifdef SNMP
if (i = snmp_init())
return i;
#endif /* SNMP */
init_vifs();
init_rp_and_bsr(); /* Must be after init_vifs() */
-
+
#ifdef RSRR
rsrr_init();
#endif /* RSRR */
-
+
sa.sa_handler = handler;
sa.sa_flags = 0; /* Interrupt system calls */
sigemptyset(&sa.sa_mask);
@@ -485,7 +485,7 @@
sigaction(SIGINT, &sa, NULL);
sigaction(SIGUSR1, &sa, NULL);
sigaction(SIGUSR2, &sa, NULL);
-
+
FD_ZERO(&readers);
FD_SET(igmp_socket, &readers);
nfds = igmp_socket + 1;
@@ -494,15 +494,15 @@
if (ihandlers[i].fd >= nfds)
nfds = ihandlers[i].fd + 1;
}
-
+
IF_DEBUG(DEBUG_IF)
dump_vifs(stderr);
IF_DEBUG(DEBUG_PIM_MRT)
dump_pim_mrt(stderr);
-
+
/* schedule first timer interrupt */
timer_setTimer(TIMER_INTERVAL, timer, NULL);
-
+
if (!debug && !foreground) {
/* Detach from the terminal */
haveterminal = 0;
@@ -516,7 +516,7 @@
(void)dup2(0, 2);
#ifdef SYSV
(void)setpgrp();
-#else
+#else
#ifdef TIOCNOTTY
n = open("/dev/tty", 2);
if (n >= 0) {
@@ -529,7 +529,7 @@
#endif /* TIOCNOTTY */
#endif /* SYSV */
} /* End of child process code */
-
+
if (pidfile(NULL)) {
warn("Cannot create pidfile");
}
@@ -537,7 +537,6 @@
/*
* Main receive loop.
*/
- dummy = 0;
dummysigalrm = SIGALRM;
difftime.tv_usec = 0;
gettimeofday(&curtime, NULL);
@@ -569,7 +568,7 @@
boottime = 0;
}
}
-
+
if (sighandled) {
if (sighandled & GOT_SIGINT) {
sighandled &= ~GOT_SIGINT;
@@ -578,7 +577,7 @@
if (sighandled & GOT_SIGHUP) {
sighandled &= ~GOT_SIGHUP;
restart(SIGHUP);
-
+
/* reconstruct readers and nfds */
FD_ZERO(&readers);
FD_SET(igmp_socket, &readers);
@@ -616,7 +615,7 @@
}
}
}
-
+
/*
* Handle timeout queue.
*
@@ -693,10 +692,10 @@
age_vifs(); /* Timeout neighbors and groups */
age_routes(); /* Timeout routing entries */
age_misc(); /* Timeout the rest (Cand-RP list, etc) */
-
+
virtual_time += TIMER_INTERVAL;
timer_setTimer(TIMER_INTERVAL, timer, NULL);
-}
+}
/*
* Performs all necessary functions to quit gracefully
@@ -706,23 +705,23 @@
{
vifi_t vifi;
struct uvif *v;
-
+
/* inform all neighbors that I'm going to die */
for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
if ((v->uv_flags &
(VIFF_DOWN | VIFF_DISABLED | VIFF_REGISTER | VIFF_TUNNEL)) == 0)
send_pim_hello(v, 0);
}
-
+
#ifdef RSRR
rsrr_clean();
#endif /* RSRR */
-
+
/* TODO: XXX (not in the spec): if I am the BSR, somehow inform the
* other routers I am going down and need to elect another BSR?
* (probably by sending a the Cand-RP-set with my_priority=LOWEST?)
*/
-
+
k_stop_pim(igmp_socket);
}
@@ -740,15 +739,15 @@
case SIGTERM:
sighandled |= GOT_SIGINT;
break;
-
+
case SIGHUP:
sighandled |= GOT_SIGHUP;
break;
-
+
case SIGUSR1:
sighandled |= GOT_SIGUSR1;
break;
-
+
case SIGUSR2:
sighandled |= GOT_SIGUSR2;
break;
@@ -765,9 +764,9 @@
#ifdef SNMP
int s;
#endif /* SNMP */
-
+
logit(LOG_NOTICE, 0, "%s % restart", versionstring);
-
+
/*
* reset all the entries
*/
@@ -791,11 +790,11 @@
#ifdef HAVE_ROUTING_SOCKETS
close(routing_socket);
#endif /* HAVE_ROUTING_SOCKETS */
-
+
/*
* start processing again
*/
-
+
init_igmp();
init_pim();
#ifdef HAVE_ROUTING_SOCKETS
@@ -817,7 +816,7 @@
{
int nxttime = 60;
void *narg = NULL;
-
+
if (arg == NULL && log_nmsgs > LOG_MAX_MSGS) {
nxttime = LOG_SHUT_UP;
narg = (void *)&log_nmsgs; /* just need some valid void * */
@@ -826,7 +825,7 @@
} else {
log_nmsgs = 0;
}
-
+
timer_setTimer(nxttime, resetlogging, narg);
}
|
[-]
[+]
|
Changed |
pimd-2.1.8.tar.bz2/mrt.c
^
|
@@ -60,7 +60,7 @@
/* Initialize the source list */
/* The first entry has address 'INADDR_ANY' and is not used */
/* The order is the smallest address first. */
- srclist = (srcentry_t *)malloc(sizeof(srcentry_t));
+ srclist = (srcentry_t *)calloc(1, sizeof(srcentry_t));
if (!srclist)
logit(LOG_ERR, 0, "Ran out of memory in init_pim_mrt()");
srclist->next = NULL;
@@ -77,7 +77,7 @@
/* Initialize the group list */
/* The first entry has address 'INADDR_ANY' and is not used */
/* The order is the smallest address first. */
- grplist = (grpentry_t *)malloc(sizeof(grpentry_t));
+ grplist = (grpentry_t *)calloc(1, sizeof(grpentry_t));
if (!grplist)
logit(LOG_ERR, 0, "Ran out of memory in init_pim_mrt()");
grplist->next = NULL;
@@ -574,7 +574,7 @@
if (search_srclist(source, &srcentry_prev) == TRUE)
return srcentry_prev;
- srcentry_ptr = (srcentry_t *)malloc(sizeof(srcentry_t));
+ srcentry_ptr = (srcentry_t *)calloc(1, sizeof(srcentry_t));
if (!srcentry_ptr) {
logit(LOG_WARNING, 0, "Memory allocation error for srcentry %s",
inet_fmt(source, s1, sizeof(s1)));
@@ -619,7 +619,7 @@
if (search_grplist(group, &grpentry_prev) == TRUE)
return grpentry_prev;
- grpentry_ptr = (grpentry_t *)malloc(sizeof(grpentry_t));
+ grpentry_ptr = (grpentry_t *)calloc(1, sizeof(grpentry_t));
if (!grpentry_ptr) {
logit(LOG_WARNING, 0, "Memory allocation error for grpentry %s",
inet_fmt(group, s1, sizeof(s1)));
@@ -767,7 +767,7 @@
u_int16 i, *i_ptr;
u_int8 vif_numbers;
- mrtentry_ptr = (mrtentry_t *)malloc(sizeof(mrtentry_t));
+ mrtentry_ptr = (mrtentry_t *)calloc(1, sizeof(mrtentry_t));
if (mrtentry_ptr == NULL) {
logit(LOG_WARNING, 0, "alloc_mrtentry(): out of memory");
return NULL;
@@ -801,12 +801,12 @@
* need to delete the routing table and disturb the forwarding.
*/
#ifdef SAVE_MEMORY
- mrtentry_ptr->vif_timers = (u_int16 *)malloc(sizeof(u_int16) * numvifs);
- mrtentry_ptr->vif_deletion_delay = (u_int16 *)malloc(sizeof(u_int16) * numvifs);
+ mrtentry_ptr->vif_timers = (u_int16 *)calloc(1, sizeof(u_int16) * numvifs);
+ mrtentry_ptr->vif_deletion_delay = (u_int16 *)calloc(1, sizeof(u_int16) * numvifs);
vif_numbers = numvifs;
#else
- mrtentry_ptr->vif_timers = (u_int16 *)malloc(sizeof(u_int16) * total_interfaces);
- mrtentry_ptr->vif_deletion_delay = (u_int16 *)malloc(sizeof(u_int16) * total_interfaces);
+ mrtentry_ptr->vif_timers = (u_int16 *)calloc(1, sizeof(u_int16) * total_interfaces);
+ mrtentry_ptr->vif_deletion_delay = (u_int16 *)calloc(1, sizeof(u_int16) * total_interfaces);
vif_numbers = total_interfaces;
#endif /* SAVE_MEMORY */
if ((mrtentry_ptr->vif_timers == NULL) ||
@@ -1034,7 +1034,7 @@
if (mrtentry_ptr->flags & MRTF_KERNEL_CACHE)
return;
- kernel_cache_new = (kernel_cache_t *)malloc(sizeof(kernel_cache_t));
+ kernel_cache_new = (kernel_cache_t *)calloc(1, sizeof(kernel_cache_t));
kernel_cache_new->next = NULL;
kernel_cache_new->prev = NULL;
kernel_cache_new->source = source;
@@ -1073,7 +1073,7 @@
* The new entry must be placed between kernel_cache_prev and
* kernel_cache_next
*/
- kernel_cache_new = (kernel_cache_t *)malloc(sizeof(kernel_cache_t));
+ kernel_cache_new = (kernel_cache_t *)calloc(1, sizeof(kernel_cache_t));
if (kernel_cache_prev != NULL)
kernel_cache_prev->next = kernel_cache_new;
else
|
[-]
[+]
|
Changed |
pimd-2.1.8.tar.bz2/pim.c
^
|
@@ -70,8 +70,8 @@
allpimrouters_group = htonl(INADDR_ALL_PIM_ROUTERS);
- pim_recv_buf = malloc(RECV_BUF_SIZE);
- pim_send_buf = malloc(SEND_BUF_SIZE);
+ pim_recv_buf = calloc(1, RECV_BUF_SIZE);
+ pim_send_buf = calloc(1, SEND_BUF_SIZE);
if (!pim_recv_buf || !pim_send_buf)
logit(LOG_ERR, 0, "Ran out of memory in init_pim()");
|
[-]
[+]
|
Changed |
pimd-2.1.8.tar.bz2/pim_proto.c
^
|
@@ -63,7 +63,7 @@
pim_nbr_entry_t *nbr, *prev_nbr, *new_nbr;
u_int16 holdtime = 0;
int bsr_length;
- u_int8 *data_ptr;
+ u_int8 *data_ptr __attribute__((unused));
srcentry_t *srcentry_ptr;
mrtentry_t *mrtentry_ptr;
@@ -136,7 +136,7 @@
* This is a new neighbor. Create a new entry for it.
* It must be added right after `prev_nbr`
*/
- new_nbr = (pim_nbr_entry_t *)malloc(sizeof(pim_nbr_entry_t));
+ new_nbr = (pim_nbr_entry_t *)calloc(1, sizeof(pim_nbr_entry_t));
if (!new_nbr)
logit(LOG_ERR, 0, "Ran out of memory in receive_pim_hello()");
new_nbr->address = src;
@@ -225,7 +225,7 @@
mrtentry_t *mrtentry_ptr;
mrtentry_t *mrtentry_srcs;
grpentry_t *grpentry_ptr;
- pim_nbr_entry_t *new_nbr;
+ pim_nbr_entry_t *new_nbr __attribute__((unused));
cand_rp_t *cand_rp_ptr;
rp_grp_entry_t *rp_grp_entry_ptr;
rpentry_t *rpentry_ptr;
@@ -541,8 +541,8 @@
}
/* XXX: not in the spec: check if I am the RP for that group */
- if ((my_cand_rp_address != reg_dst)
- || (check_mrtentry_rp(mrtentry_ptr, my_cand_rp_address) == FALSE)) {
+ if ((local_address(reg_dst) == NO_VIF) ||
+ (check_mrtentry_rp(mrtentry_ptr, reg_dst) == FALSE)) {
send_pim_register_stop(reg_dst, reg_src, inner_grp, inner_src);
return TRUE;
@@ -1024,7 +1024,7 @@
u_int32 s_mask;
u_int32 g_mask;
u_int8 s_flags;
- u_int8 reserved;
+ u_int8 reserved __attribute__((unused));
rpentry_t *rpentry_ptr;
mrtentry_t *mrtentry_ptr;
mrtentry_t *mrtentry_srcs;
@@ -2171,12 +2171,12 @@
build_jp_message_t *bjpm_ptr;
if (build_jp_message_pool_counter == 0) {
- bjpm_ptr = (build_jp_message_t *)malloc(sizeof(build_jp_message_t));
+ bjpm_ptr = (build_jp_message_t *)calloc(1, sizeof(build_jp_message_t));
if (!bjpm_ptr)
return NULL;
bjpm_ptr->next = (build_jp_message_t *)NULL;
- bjpm_ptr->jp_message = (u_int8 *)malloc(MAX_JP_MESSAGE_SIZE +
+ bjpm_ptr->jp_message = (u_int8 *)calloc(1, MAX_JP_MESSAGE_SIZE +
sizeof(pim_jp_encod_grp_t) +
2 * sizeof(pim_encod_src_addr_t));
if (!bjpm_ptr->jp_message) {
@@ -2187,7 +2187,7 @@
bjpm_ptr->jp_message_size = 0;
bjpm_ptr->join_list_size = 0;
bjpm_ptr->join_addr_number = 0;
- bjpm_ptr->join_list = (u_int8 *)malloc(MAX_JOIN_LIST_SIZE +
+ bjpm_ptr->join_list = (u_int8 *)calloc(1, MAX_JOIN_LIST_SIZE +
sizeof(pim_encod_src_addr_t));
if (!bjpm_ptr->join_list) {
free(bjpm_ptr->jp_message);
@@ -2196,7 +2196,7 @@
}
bjpm_ptr->prune_list_size = 0;
bjpm_ptr->prune_addr_number = 0;
- bjpm_ptr->prune_list = (u_int8 *)malloc(MAX_PRUNE_LIST_SIZE +
+ bjpm_ptr->prune_list = (u_int8 *)calloc(1, MAX_PRUNE_LIST_SIZE +
sizeof(pim_encod_src_addr_t));
if (!bjpm_ptr->prune_list) {
free(bjpm_ptr->join_list);
@@ -2206,7 +2206,7 @@
}
bjpm_ptr->rp_list_join_size = 0;
bjpm_ptr->rp_list_join_number = 0;
- bjpm_ptr->rp_list_join = (u_int8 *)malloc(MAX_JOIN_LIST_SIZE +
+ bjpm_ptr->rp_list_join = (u_int8 *)calloc(1, MAX_JOIN_LIST_SIZE +
sizeof(pim_encod_src_addr_t));
if (!bjpm_ptr->rp_list_join) {
free(bjpm_ptr->prune_list);
@@ -2217,7 +2217,7 @@
}
bjpm_ptr->rp_list_prune_size = 0;
bjpm_ptr->rp_list_prune_number = 0;
- bjpm_ptr->rp_list_prune = (u_int8 *)malloc(MAX_PRUNE_LIST_SIZE +
+ bjpm_ptr->rp_list_prune = (u_int8 *)calloc(1, MAX_PRUNE_LIST_SIZE +
sizeof(pim_encod_src_addr_t));
if (!bjpm_ptr->rp_list_prune) {
free(bjpm_ptr->rp_list_join);
@@ -2368,7 +2368,7 @@
datalen = pim_nbr->build_jp_message->jp_message_size;
vifi = pim_nbr->vifi;
- memcpy(pim_send_buf + sizeof(struct ip) + sizeof(pim_header_t),
+ memcpy(pim_send_buf + sizeof(struct ip) + sizeof(pim_header_t),
pim_nbr->build_jp_message->jp_message, datalen);
send_pim(pim_send_buf, uvifs[vifi].uv_lcl_addr, allpimrouters_group,
PIM_JOIN_PRUNE, datalen);
@@ -2645,7 +2645,7 @@
u_int8 *data_start_ptr;
u_int32 local_preference;
u_int32 local_metric;
- srcentry_t *srcentry_ptr;
+ srcentry_t *srcentry_ptr __attribute__((unused));
/* Don't send assert if the outgoing interface a tunnel or register vif */
/* TODO: XXX: in the code above asserts are accepted over VIFF_TUNNEL.
@@ -2746,7 +2746,7 @@
pim_encod_uni_addr_t new_bsr_uni_addr;
u_int32 new_bsr_address;
struct rpfctl rpfc;
- pim_nbr_entry_t *n, *rpf_neighbor;
+ pim_nbr_entry_t *n, *rpf_neighbor __attribute__((unused));
u_int32 neighbor_addr;
vifi_t vifi, incoming = NO_VIF;
int min_datalen;
@@ -2754,10 +2754,10 @@
pim_encod_uni_addr_t curr_rp_addr;
u_int8 curr_rp_count;
u_int8 curr_frag_rp_count;
- u_int16 reserved_short;
+ u_int16 reserved_short __attribute__((unused));
u_int16 curr_rp_holdtime;
u_int8 curr_rp_priority;
- u_int8 reserved_byte;
+ u_int8 reserved_byte __attribute__((unused));
u_int32 curr_group_mask;
u_int32 prefix_h;
grp_mask_t *grp_mask_ptr;
|
[-]
[+]
|
Changed |
pimd-2.1.8.tar.bz2/pimd.8
^
|
@@ -171,11 +171,12 @@
.Op Cm priority Ar <number>
.It
.Cm rp_address
-.Ar <rp-addr|group-addr>
+.Ar <rp-addr> [<group-addr> [masklen <masklen] [priority <number>]]
.It
.Cm group_prefix
.Ar <group-addr>
.Op Cm masklen Ar <masklen>
+.Op Cm priority Ar <number>
.It
.Cm switch_data_threshold
.Op Cm rate Ar <number> Cm interval Ar <number>
@@ -300,7 +301,8 @@
The
.Nm rp_address
setting is for static Rendez-vous Point configurations. The argument can either
-be a unicast address or a multicast group.
+be a unicast address or a multicast group, with an optional group address,
+mask length, and priority arguments.
.Pp
The
.Nm switch_data_threshold
|
[-]
[+]
|
Changed |
pimd-2.1.8.tar.bz2/pimd.conf
^
|
@@ -15,7 +15,7 @@
#
# cand_rp [<local-addr>] [priority <number> ] [time <number>]
# cand_bootstrap_router [<local-addr>] [priority <number>]
-# rp_address <rp-addr>
+# rp_address <rp-addr> [<group-addr> [masklen <masklen>] [priority <number>]]
#
# group_prefix <group-addr> [masklen <masklen>]
# group_prefix <group-addr> [masklen <masklen>]
@@ -78,7 +78,8 @@
# `group_prefix` is/are the prefix(es) advertised if cand_rp
#
# It is possible to set a static Rendez-Vous Point using the "rp_address"
-# setting. The argument can be either a unicast or a multicast address.
+# setting. The argument can be either a unicast or a multicast address
+# followed by an optional group address and optional masklen to that.
#
# `rate` specifies the minimum rate in bits/s before the last hop
# router or the RP switch to the shortest path (`switch_data_threshold`
@@ -103,7 +104,7 @@
cand_bootstrap_router priority 5
# Static rendez-vous point
-#rp_address 192.168.10.1
+#rp_address 192.168.10.1 224.0.0.0 masklen 8 priority 5
# All multicast groups
group_prefix 224.0.0.0 masklen 4
|
[-]
[+]
|
Changed |
pimd-2.1.8.tar.bz2/pimd.h
^
|
@@ -45,6 +45,9 @@
#define PIMD_LEVEL (PIM_CONSTANT | PIMD_VERSION | (PIMD_SUBVERSION << 8))
#define INADDR_ALL_PIM_ROUTERS (u_int32)0xe000000D /* 224.0.0.13 */
+#if !defined(INADDR_UNSPEC_GROUP)
+#define INADDR_UNSPEC_GROUP (u_int32)0xe0000000 /* 224.0.0.0 */
+#endif /* !defined(INADDR_UNSPEC_GROUP) */
/* PIM protocol timers (in seconds) */
@@ -77,6 +80,7 @@
* See the PS version (Mar' 97),
* pp.22 bottom of the spec.
*/
+#define PIM_MAX_CAND_RP_PRIORITY 255 /* 255 is the highest. */
#define PIM_DEFAULT_BSR_PRIORITY 0 /* 0 is the lowest */
#define RP_DEFAULT_IPV4_HASHMASKLEN 30 /* the default group msklen used
* by the hash function to
@@ -92,6 +96,7 @@
* may concentrate all multicast
* traffic in a single RP
*/
+#define PIM_GROUP_PREFIX_MIN_MASKLEN 4 /* group prefix minimum length */
/* Datarate related definitions */
/* REG_RATE is used by the RP to switch to the shortest path instead of
|
[-]
[+]
|
Changed |
pimd-2.1.8.tar.bz2/route.c
^
|
@@ -464,11 +464,11 @@
u_int16 flags)
{
vifbitmap_t new_joined_oifs; /* The oifs for that particular mrtentry */
- vifbitmap_t old_joined_oifs;
- vifbitmap_t old_pruned_oifs;
- vifbitmap_t old_leaves;
+ vifbitmap_t old_joined_oifs __attribute__ ((unused));
+ vifbitmap_t old_pruned_oifs __attribute__ ((unused));
+ vifbitmap_t old_leaves __attribute__ ((unused));
vifbitmap_t new_leaves;
- vifbitmap_t old_asserted_oifs;
+ vifbitmap_t old_asserted_oifs __attribute__ ((unused));
vifbitmap_t new_real_oifs; /* The result oifs */
vifbitmap_t old_real_oifs;
vifi_t old_iif;
|
[-]
[+]
|
Changed |
pimd-2.1.8.tar.bz2/rp.c
^
|
@@ -193,7 +193,7 @@
}
/* Create and insert the new entry between prev and next */
- ptr = (cand_rp_t *)malloc(sizeof(cand_rp_t));
+ ptr = (cand_rp_t *)calloc(1, sizeof(cand_rp_t));
if (!ptr)
logit(LOG_ERR, 0, "Ran out of memory in add_cand_rp()");
ptr->rp_grp_next = NULL;
@@ -206,7 +206,7 @@
else
prev->next = ptr;
- entry = (rpentry_t *)malloc(sizeof(rpentry_t));
+ entry = (rpentry_t *)calloc(1, sizeof(rpentry_t));
if (!entry)
logit(LOG_ERR, 0, "Ran out of memory in add_cand_rp()");
ptr->rpentry = entry;
@@ -259,7 +259,7 @@
}
}
- ptr = (grp_mask_t *)malloc(sizeof(grp_mask_t));
+ ptr = (grp_mask_t *)calloc(1, sizeof(grp_mask_t));
if (!ptr)
logit(LOG_ERR, 0, "Ran out of memory in add_grp_mask()");
@@ -385,7 +385,7 @@
}
/* Create and link the new entry */
- entry_new = (rp_grp_entry_t *)malloc(sizeof(rp_grp_entry_t));
+ entry_new = (rp_grp_entry_t *)calloc(1, sizeof(rp_grp_entry_t));
if (!entry_new)
logit(LOG_ERR, 0, "Ran out of memory in add_rp_grp_entry()");
entry_new->grp_rp_next = entry_next;
|
[-]
[+]
|
Changed |
pimd-2.1.8.tar.bz2/rsrr.c
^
|
@@ -68,8 +68,8 @@
int servlen;
struct sockaddr_un serv_addr;
- rsrr_recv_buf = (char *)malloc(RSRR_MAX_LEN);
- rsrr_send_buf = (char *)malloc(RSRR_MAX_LEN);
+ rsrr_recv_buf = (char *)calloc(1, RSRR_MAX_LEN);
+ rsrr_send_buf = (char *)calloc(1, RSRR_MAX_LEN);
if (!rsrr_recv_buf || !rsrr_send_buf)
logit(LOG_ERR, 0, "Ran out of memory in rsrr_init()");
@@ -483,7 +483,7 @@
/* Cache entry doesn't already exist. Create one and insert at
* front of list.
*/
- rc = (struct rsrr_cache *)malloc(sizeof(struct rsrr_cache));
+ rc = (struct rsrr_cache *)calloc(1, sizeof(struct rsrr_cache));
if (rc == NULL)
logit(LOG_ERR, 0, "Ran out of memory in rsrr_cache()");
|
[-]
[+]
|
Changed |
pimd-2.1.8.tar.bz2/vif.c
^
|
@@ -70,7 +70,7 @@
vifi_t vifi;
struct uvif *v;
int enabled_vifs;
-
+
numvifs = 0;
reg_vif_num = NO_VIF;
vifs_down = FALSE;
@@ -106,7 +106,7 @@
*/
enabled_vifs = 0;
phys_vif = -1;
-
+
for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
/* Initialize the outgoing timeout for each vif. Currently use a fixed time
* 'PIM_JOIN_PRUNE_HOLDTIME'. Later, may add a configurable array to feed
@@ -124,10 +124,10 @@
if (enabled_vifs < 1) /* XXX: TODO: */
logit(LOG_ERR, 0, "Cannot forward: %s", enabled_vifs == 0 ? "no enabled vifs" : "only one enabled vif");
-
+
k_init_pim(igmp_socket); /* Call to kernel to initialize structures */
- /* Add a dummy virtual interface to support Registers in the kernel.
+ /* Add a dummy virtual interface to support Registers in the kernel.
* In order for this to work, the kernel has to have been modified
* with the PIM patches to ip_mroute.{c,h} and ip.c
*/
@@ -183,7 +183,7 @@
{
struct uvif *v;
vifi_t i;
-
+
v = &uvifs[numvifs];
v->uv_flags = 0;
@@ -193,20 +193,20 @@
return FALSE;
}
-
+
/*
* So far in PIM we need only one register vif and we save its number in
* the global reg_vif_num.
*/
reg_vif_num = numvifs;
-
+
/* set the REGISTER flag */
v->uv_flags = VIFF_REGISTER;
#ifdef PIM_EXPERIMENTAL
v->uv_flags |= VIFF_REGISTER_KERNEL_ENCAP;
#endif
strlcpy(v->uv_name, "register_vif0", sizeof(v->uv_name));
-
+
/* Use the address of the first available physical interface to
* create the register vif.
*/
@@ -287,12 +287,10 @@
static void start_vif(vifi_t vifi)
{
struct uvif *v;
- u_int32 src;
v = &uvifs[vifi];
- src = v->uv_lcl_addr;
/* Initialy no router on any vif */
- if (v->uv_flags & VIFF_REGISTER)
+ if (v->uv_flags & VIFF_REGISTER)
v->uv_flags = v->uv_flags & ~VIFF_DOWN;
else {
v->uv_flags = (v->uv_flags | VIFF_DR | VIFF_NONBRS) & ~VIFF_DOWN;
@@ -302,24 +300,24 @@
RESET_TIMER(v->uv_gq_timer);
v->uv_pim_neighbors = (pim_nbr_entry_t *)NULL;
}
-
+
/* Tell kernel to add, i.e. start this vif */
- k_add_vif(igmp_socket, vifi, &uvifs[vifi]);
+ k_add_vif(igmp_socket, vifi, &uvifs[vifi]);
logit(LOG_INFO, 0, "Interface %s comes up; vif #%u now in service", v->uv_name, vifi);
-
+
if (!(v->uv_flags & VIFF_REGISTER)) {
/*
* Join the PIM multicast group on the interface.
*/
k_join(igmp_socket, allpimrouters_group, v);
-
+
/*
* Join the ALL-ROUTERS multicast group on the interface.
* This allows mtrace requests to loop back if they are run
* on the multicast router.
*/
k_join(igmp_socket, allrouters_group, v);
-
+
/*
* Until neighbors are discovered, assume responsibility for sending
* periodic group membership queries to the subnet. Send the first
@@ -327,7 +325,7 @@
*/
v->uv_flags |= VIFF_QUERIER;
query_groups(v);
-
+
/*
* Send a probe via the new vif to look for neighbors.
*/
@@ -336,7 +334,7 @@
#ifdef __linux__
else {
struct ifreq ifr;
-
+
memset(&ifr, 0, sizeof(struct ifreq));
/* strlcpy(ifr.ifr_name,v->uv_name, IFNAMSIZ); */
strlcpy(ifr.ifr_name, "pimreg", IFNAMSIZ);
@@ -361,11 +359,11 @@
struct listaddr *a;
pim_nbr_entry_t *n, *next;
struct vif_acl *acl;
-
+
/*
- * TODO: make sure that the kernel viftable is
+ * TODO: make sure that the kernel viftable is
* consistent with the daemon table
- */
+ */
v = &uvifs[vifi];
if (!(v->uv_flags & VIFF_REGISTER)) {
k_leave(igmp_socket, allpimrouters_group, v);
@@ -380,14 +378,14 @@
free((char *)a);
}
}
-
+
/*
* TODO: inform (eventually) the neighbors I am going down by sending
* PIM_HELLO with holdtime=0 so someone else should become a DR.
- */
+ */
/* TODO: dummy! Implement it!! Any problems if don't use it? */
delete_vif_from_mrt(vifi);
-
+
/* Delete the interface from the kernel's vif structure. */
k_del_vif(igmp_socket, vifi, v);
@@ -414,7 +412,7 @@
vifs_down = TRUE;
logit(LOG_INFO, 0, "Interface %s goes down; vif #%u out of service", v->uv_name, vifi);
-}
+}
/*
@@ -484,7 +482,7 @@
for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
if (v->uv_flags & (VIFF_DISABLED | VIFF_REGISTER))
continue;
-
+
/* get the interface flags */
strlcpy(ifr.ifr_name, v->uv_name, sizeof(ifr.ifr_name));
if (ioctl(udp_socket, SIOCGIFFLAGS, (char *)&ifr) < 0) {
@@ -517,7 +515,7 @@
vifi_t vifi2;
struct uvif *v2;
int found;
-
+
if (!(v->uv_flags & VIFF_REGISTER))
continue;
@@ -557,7 +555,7 @@
vifi_t vifi;
struct uvif *v;
struct phaddr *p;
-
+
for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
if (v->uv_flags & (VIFF_DISABLED | VIFF_DOWN | VIFF_REGISTER | VIFF_TUNNEL))
continue;
@@ -565,7 +563,7 @@
if (src == v->uv_lcl_addr)
return NO_VIF; /* src is one of our IP addresses */
- if ((src & v->uv_subnetmask) == v->uv_subnet &&
+ if ((src & v->uv_subnetmask) == v->uv_subnet &&
((v->uv_subnetmask == 0xffffffff) ||
(src != v->uv_subnetbcast)))
return vifi;
@@ -585,7 +583,7 @@
}
return NO_VIF;
-}
+}
/*
@@ -596,7 +594,7 @@
{
vifi_t vifi;
struct uvif *v;
-
+
for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
/* TODO: XXX: what about VIFF_TUNNEL? */
if (v->uv_flags & (VIFF_DISABLED | VIFF_DOWN | VIFF_REGISTER))
@@ -604,12 +602,12 @@
if (src != v->uv_lcl_addr)
continue;
- else
+ else
return vifi;
}
/* Returning NO_VIF means not a local address */
- return NO_VIF;
+ return NO_VIF;
}
/*
@@ -623,7 +621,7 @@
vifi_t vifi;
struct uvif *v;
struct phaddr *p;
-
+
for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
/* TODO: XXX: what about VIFF_TUNNEL? */
if (v->uv_flags & (VIFF_DISABLED | VIFF_DOWN | VIFF_REGISTER | VIFF_TUNNEL))
@@ -651,7 +649,7 @@
return vifi;
}
return NO_VIF;
-}
+}
/*
* Returns the highest address of local vif that is UP and ENABLED.
@@ -662,7 +660,7 @@
vifi_t vifi;
struct uvif *v;
u_int32 max_address = 0;
-
+
for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
/* Count vif if not DISABLED or DOWN */
/* TODO: XXX: What about VIFF_TUNNEL? */
|