1 diff -ur --exclude='*.o' --exclude=cfparse.c --exclude='*~' mrouted-3.9.5/config.c mrouted-3.9.5-pl/config.c
2 --- mrouted-3.9.5/config.c 2011-03-05 21:45:25.000000000 +0100
3 +++ mrouted-3.9.5-pl/config.c 2011-08-29 16:32:43.710565000 +0200
5 v->uv_subnetbcast = subnet | ~mask;
6 strncpy(v->uv_name, ifa->ifa_name, sizeof(v->uv_name));
8 - if (flags & IFF_POINTOPOINT)
9 + if (flags & IFF_POINTOPOINT) {
10 v->uv_flags |= VIFF_REXMIT_PRUNES;
11 + v->uv_ptp_addr = ((struct sockaddr_in *)ifa->ifa_dstaddr)->sin_addr.s_addr;
13 + { /* getifaddr doesn't give us the p2p link reliably */
14 + /* So use ip, which uses netlink, to query it */
19 + logit(LOG_INFO,0,"Getting ptp for %s", ifa->ifa_name);
21 + snprintf(buf,sizeof(buf),"ip addr show %s | grep -o 'peer [0-9.]*' | grep -o '[0-9.]*'", ifa->ifa_name);
22 + peer = popen(buf, "r");
23 + rode = fread(buf, 1, sizeof(buf), peer);
27 + /* It has a pointopoint address */
28 + struct in_addr ptp_in;
30 + for (--rode; rode && buf[rode] <= 13;)
34 + logit(LOG_INFO,0,"Got %s", buf);
36 + if (inet_aton(buf, &ptp_in))
37 + v->uv_ptp_addr = ptp_in.s_addr;
41 - logit(LOG_INFO,0,"installing %s (%s on subnet %s) as vif #%u - rate=%d",
42 + logit(LOG_INFO,0,"installing %s (%s on subnet %s%s%s) as vif #%u - rate=%d",
43 v->uv_name, inet_fmt(addr, s1, sizeof(s1)), inet_fmts(subnet, mask, s2, sizeof(s2)),
44 + (v->uv_ptp_addr) ? "peer " : "", (v->uv_ptp_addr) ? inet_fmt(v->uv_ptp_addr, s3, sizeof(s3)) : "",
45 numvifs, v->uv_rate_limit);
48 diff -ur --exclude='*.o' --exclude=cfparse.c --exclude='*~' mrouted-3.9.5/defs.h mrouted-3.9.5-pl/defs.h
49 --- mrouted-3.9.5/defs.h 2011-03-05 21:45:25.000000000 +0100
50 +++ mrouted-3.9.5-pl/defs.h 2011-08-30 15:30:23.691662000 +0200
52 #ifndef __MROUTED_DEFS_H__
53 #define __MROUTED_DEFS_H__
64 +#include <arpa/inet.h>
65 #include <netinet/in.h>
66 #include <netinet/in_systm.h>
67 #include <netinet/ip.h>
73 +#if defined(RSRR) || defined(PLANETLAB)
78 extern u_int32 dvmrp_group;
79 extern u_int32 dvmrp_genid;
82 +extern int plrt_socket;
83 +extern char *plrt_socket_path;
86 #define IF_DEBUG(l) if (debug && debug & (l))
88 #define DEBUG_PKT 0x0001
90 extern void k_leave(u_int32, u_int32);
91 extern void k_init_dvmrp(void);
92 extern void k_stop_dvmrp(void);
93 +extern void k_init_plrt(void);
94 +extern void k_stop_plrt(void);
95 extern void k_add_vif(vifi_t, struct uvif *);
96 extern void k_del_vif(vifi_t, struct uvif *);
97 extern void k_add_rg(u_int32, struct gtable *);
98 diff -ur --exclude='*.o' --exclude=cfparse.c --exclude='*~' mrouted-3.9.5/igmp.c mrouted-3.9.5-pl/igmp.c
99 --- mrouted-3.9.5/igmp.c 2011-03-05 21:45:25.000000000 +0100
100 +++ mrouted-3.9.5-pl/igmp.c 2011-08-29 17:03:24.187961000 +0200
103 if (src == 0 || dst == 0)
104 logit(LOG_WARNING, 0, "kernel request not accurate");
107 + logit(LOG_DEBUG, 0, "received kernel miss");
108 add_table_entry(src, dst);
113 diff -ur --exclude='*.o' --exclude=cfparse.c --exclude='*~' mrouted-3.9.5/kern.c mrouted-3.9.5-pl/kern.c
114 --- mrouted-3.9.5/kern.c 2011-03-05 21:45:25.000000000 +0100
115 +++ mrouted-3.9.5-pl/kern.c 2011-08-31 15:09:21.457071000 +0200
117 * Leland Stanford Junior University.
128 +char *plrt_socket_path = _PATH_MROUTED_PLRT;
133 * Open/init the multicast routing in the kernel and sets the
134 * MRT_PIM (aka MRT_ASSERT) flag in the kernel.
136 void k_init_dvmrp(void)
141 if (setsockopt(igmp_socket, IPPROTO_IP, MRT_INIT, (char *)NULL, 0) < 0) {
145 if (setsockopt(igmp_socket, IPPROTO_IP, MRT_INIT, (char *)&v, sizeof(int)) < 0) {
148 if (errno == EADDRINUSE)
149 logit(LOG_ERR, 0, "Another multicast routing application is already running.");
151 logit(LOG_ERR, errno, "Cannot enable multicast routing in kernel");
157 +void k_init_plrt(void)
161 + * Just open a connection to the user-space forwarder
164 + if ((plrt_socket = socket(AF_UNIX, SOCK_SEQPACKET, 0)) < 0)
165 + logit(LOG_ERR, errno, "PLRT socket");
167 + struct sockaddr_un sun;
168 + memset(&sun, 0, sizeof(sun));
169 + sun.sun_family = AF_UNIX;
170 + strncpy(sun.sun_path, plrt_socket_path, sizeof(sun.sun_path));
172 + if ((connect(plrt_socket, &sun, sizeof(sun))) < 0)
173 + logit(LOG_ERR, errno, "PLRT socket connect");
180 void k_stop_dvmrp(void)
183 if (setsockopt(igmp_socket, IPPROTO_IP, MRT_DONE, (char *)NULL, 0) < 0)
184 logit(LOG_WARNING, errno, "Cannot disable multicast routing in kernel");
188 +void k_stop_plrt(void)
191 + close(plrt_socket);
196 @@ -194,11 +236,25 @@
198 void k_add_vif(vifi_t vifi, struct uvif *v)
202 - vc.vifc_vifi = vifi;
203 - uvif_to_vifctl(&vc, v);
204 - if (setsockopt(igmp_socket, IPPROTO_IP, MRT_ADD_VIF, (char *)&vc, sizeof(vc)) < 0)
206 + * PlanetLab does application-level forwarding
214 + op.vc.vifc_vifi = vifi;
215 + uvif_to_vifctl(&op.vc, v);
218 + op.op = MRT_ADD_VIF;
219 + op.len = sizeof(op.vc);
220 + if (send(plrt_socket, &op, sizeof(op), 0) < 0)
222 + if (setsockopt(igmp_socket, IPPROTO_IP, MRT_ADD_VIF, (char *)&op.vc, sizeof(op.vc)) < 0)
224 logit(LOG_ERR, errno, "setsockopt MRT_ADD_VIF on vif %d", vifi);
228 * we're going to delete. *BSD systems on the other hand exepect only the index
238 + op.vc.vifc_vifi = vifi;
239 + uvif_to_vifctl(&op.vc, v);
241 + op.op = MRT_DEL_VIF;
242 + op.len = sizeof(op.vc);
243 + if (send(plrt_socket, &op, sizeof(op), 0) < 0)
249 #else /* *BSD et al. */
250 if (setsockopt(igmp_socket, IPPROTO_IP, MRT_DEL_VIF, (char *)&vifi, sizeof(vifi)) < 0)
251 #endif /* !__linux__ */
252 +#endif /* PLANETLAB */
254 if (errno == EADDRNOTAVAIL || errno == EINVAL)
256 @@ -238,31 +309,57 @@
258 void k_add_rg(u_int32 origin, struct gtable *g)
270 md_log(MD_ADD, origin, g->gt_mcastgrp);
272 /* copy table values so that setsockopt can process it */
273 - mc.mfcc_origin.s_addr = origin;
274 + op.mc.mfcc_origin.s_addr = origin;
276 - mc.mfcc_originmask.s_addr = 0xffffffff;
277 + op.mc.mfcc_originmask.s_addr = 0xffffffff;
279 - mc.mfcc_mcastgrp.s_addr = g->gt_mcastgrp;
280 - mc.mfcc_parent = g->gt_route ? g->gt_route->rt_parent : NO_VIF;
281 + op.mc.mfcc_mcastgrp.s_addr = g->gt_mcastgrp;
282 + op.mc.mfcc_parent = g->gt_route ? g->gt_route->rt_parent : NO_VIF;
283 for (i = 0; i < numvifs; i++)
284 - mc.mfcc_ttls[i] = g->gt_ttls[i];
285 + op.mc.mfcc_ttls[i] = g->gt_ttls[i];
289 + logit(LOG_DEBUG, 0, "setsockopt MRT_ADD_MFC %s-%s %d[%d %d %d %d %d %d]",
290 + inet_fmt(origin, s1, sizeof(s1)),
291 + inet_fmt(g->gt_mcastgrp, s2, sizeof(s2)),
293 + op.mc.mfcc_ttls[0], op.mc.mfcc_ttls[1], op.mc.mfcc_ttls[2],
294 + op.mc.mfcc_ttls[3], op.mc.mfcc_ttls[4], op.mc.mfcc_ttls[5] );
296 + /* Send to PlanetLab's user-space MRT daemon */
297 + op.op = MRT_ADD_MFC;
298 + op.len = sizeof(op.mc);
299 + if (send(plrt_socket, &op, sizeof(op), 0) < 0)
301 +#else /* here if not PLANETLAB */
303 /* write to kernel space */
304 if (setsockopt(igmp_socket, IPPROTO_IP, MRT_ADD_MFC,
305 - (char *)&mc, sizeof(mc)) < 0) {
306 + (char *)&op.mc, sizeof(op.mc)) < 0)
308 +#endif /* PLANETLAB */
312 md_log(MD_ADD_FAIL, origin, g->gt_mcastgrp);
314 logit(LOG_WARNING, errno, "setsockopt MRT_ADD_MFC",
315 inet_fmt(origin, s1, sizeof(s1)), inet_fmt(g->gt_mcastgrp, s2, sizeof(s2)));
321 @@ -271,20 +368,37 @@
323 int k_del_rg(u_int32 origin, struct gtable *g)
333 md_log(MD_DEL, origin, g->gt_mcastgrp);
335 /* copy table values so that setsockopt can process it */
336 - mc.mfcc_origin.s_addr = origin;
337 + op.mc.mfcc_origin.s_addr = origin;
339 - mc.mfcc_originmask.s_addr = 0xffffffff;
340 + op.mc.mfcc_originmask.s_addr = 0xffffffff;
342 - mc.mfcc_mcastgrp.s_addr = g->gt_mcastgrp;
343 + op.mc.mfcc_mcastgrp.s_addr = g->gt_mcastgrp;
347 + /* Send to PlanetLab's user-space MRT daemon */
348 + op.op = MRT_DEL_MFC;
349 + op.len = sizeof(op.mc);
350 + if (send(plrt_socket, &op, sizeof(op), 0) < 0)
352 +#else /* here if not PLANETLAB */
354 /* write to kernel space */
355 - if (setsockopt(igmp_socket, IPPROTO_IP, MRT_DEL_MFC, (char *)&mc, sizeof(mc)) < 0) {
356 + if (setsockopt(igmp_socket, IPPROTO_IP, MRT_DEL_MFC, (char *)&op.mc, sizeof(op.mc)) < 0)
358 +#endif /* PLANETLAB */
362 md_log(MD_DEL_FAIL, origin, g->gt_mcastgrp);
364 diff -ur --exclude='*.o' --exclude=cfparse.c --exclude='*~' mrouted-3.9.5/main.c mrouted-3.9.5-pl/main.c
365 --- mrouted-3.9.5/main.c 2011-03-05 21:45:25.000000000 +0100
366 +++ mrouted-3.9.5-pl/main.c 2011-08-30 15:31:01.281814000 +0200
368 time_t mrouted_init_time;
371 -#define NHANDLERS 34
372 +#define NHANDLERS 35
378 static struct ihandler {
380 fputs(" -h, --help Show this help text\n", stderr);
381 fputs(" -p Disable pruning. Deprecated, compatibility option\n", stderr);
382 fputs(" -r, --show-routes Show state of VIFs and multicast routing tables\n", stderr);
384 + fputs(" -F Path to the PlanetLab userland forwarder, default /var/run/mcastfwd\n", stderr);
386 fprintf(stderr, " -v, --version Show %s version\n", __progname);
389 @@ -258,11 +261,23 @@
391 snprintf(versionstring, sizeof(versionstring), "mrouted version %s", todaysversion);
393 - while ((ch = getopt_long(argc, argv, "c:d::fhpP::rv", long_options, NULL)) != EOF) {
395 +#define PLOPTIONS ":F"
397 +#define PLOPTIONS ""
400 + while ((ch = getopt_long(argc, argv, "c:d::fhpP::rv" PLOPTIONS, long_options, NULL)) != EOF) {
403 configfilename = optarg;
408 + plrt_socket_path = optarg;
422 * Unfortunately, you can't k_get_version() unless you've
425 vers = k_get_version();
429 * This function must change whenever the kernel version changes
432 logit(LOG_ERR, 0, "Descriptor too big");
433 FD_SET(igmp_socket, &readers);
434 nfds = igmp_socket + 1;
437 + if (plrt_socket >= (int)FD_SETSIZE)
438 + logit(LOG_ERR, 0, "Descriptor too big");
439 + FD_SET(plrt_socket, &readers);
440 + if (plrt_socket >= nfds)
441 + nfds = plrt_socket + 1;
444 for (i = 0; i < nhandlers; i++) {
445 if (ihandlers[i].fd >= (int)FD_SETSIZE)
446 logit(LOG_ERR, 0, "Descriptor too big");
448 accept_igmp(recvlen);
452 + if (FD_ISSET(plrt_socket, &rfds)) {
453 + recvlen = recvfrom(plrt_socket, recv_buf, RECV_BUF_SIZE, 0, NULL, &dummy);
455 + if (errno != EINTR) logit(LOG_ERR, errno, "recvfrom");
458 + if (did_final_init) accept_igmp(recvlen);
462 for (i = 0; i < nhandlers; i++) {
463 if (FD_ISSET(ihandlers[i].fd, &rfds)) {
464 (*ihandlers[i].func)(ihandlers[i].fd, &rfds);
473 diff -ur --exclude='*.o' --exclude=cfparse.c --exclude='*~' mrouted-3.9.5/Makefile mrouted-3.9.5-pl/Makefile
474 --- mrouted-3.9.5/Makefile 2011-03-05 21:45:25.000000000 +0100
475 +++ mrouted-3.9.5-pl/Makefile 2011-08-10 17:18:22.233596000 +0200
479 CFLAGS = $(MCAST_INCLUDE) $(SNMPDEF) $(RSRRDEF) $(INCLUDES) $(DEFS) $(USERCOMPILE)
480 -CFLAGS += -O2 -W -Wall -Werror
481 +CFLAGS += -O2 -W -Wall
483 LDLIBS = $(SNMPLIBDIR) $(SNMPLIBS) $(EXTRA_LIBS)
484 LDFLAGS += -Wl,-Map,$@.map
485 Only in mrouted-3.9.5-pl: Makefile.bk
486 Only in mrouted-3.9.5-pl: map-mbone
487 Only in mrouted-3.9.5-pl: map-mbone.map
488 Only in mrouted-3.9.5-pl: mrinfo
489 Only in mrouted-3.9.5-pl: mrinfo.map
490 Only in mrouted-3.9.5-pl: mrouted
491 Only in mrouted-3.9.5-pl: mrouted.map
492 Only in mrouted-3.9.5-pl: mtrace
493 Only in mrouted-3.9.5-pl: mtrace.map
494 diff -ur --exclude='*.o' --exclude=cfparse.c --exclude='*~' mrouted-3.9.5/pathnames.h mrouted-3.9.5-pl/pathnames.h
495 --- mrouted-3.9.5/pathnames.h 2011-03-05 21:45:25.000000000 +0100
496 +++ mrouted-3.9.5-pl/pathnames.h 2011-08-29 13:10:27.043684000 +0200
498 #define _PATH_MROUTED_GENID _PATH_MROUTED_RUNDIR "/mrouted.genid"
499 #define _PATH_MROUTED_DUMP _PATH_MROUTED_RUNDIR "/mrouted.dump"
500 #define _PATH_MROUTED_CACHE _PATH_MROUTED_RUNDIR "/mrouted.cache"
501 +#define _PATH_MROUTED_PLRT _PATH_VARRUN "mcastrt"
503 #endif /* __MROUTED_PATHNAMES_H__ */
504 Only in mrouted-3.9.5-pl: vers.c
505 diff -ur --exclude='*.o' --exclude=cfparse.c --exclude='*~' mrouted-3.9.5/vif.c mrouted-3.9.5-pl/vif.c
506 --- mrouted-3.9.5/vif.c 2011-03-05 21:45:25.000000000 +0100
507 +++ mrouted-3.9.5-pl/vif.c 2011-08-31 19:26:52.955453000 +0200
511 v->uv_dst_addr = t ? 0 : dvmrp_group;
512 + v->uv_ptp_addr = 0;
514 v->uv_subnetmask = 0;
515 v->uv_subnetbcast = 0;
517 start_route_updates();
518 update_route(p->pa_subnet, p->pa_subnetmask, 0, 0, vifi, NULL);
520 + if (v->uv_ptp_addr)
521 + update_route(v->uv_ptp_addr, 0xffffffff, 0, 0, vifi, NULL);
524 * Until neighbors are discovered, assume responsibility for sending
529 + if (src == v->uv_ptp_addr)
531 if ((src & v->uv_subnetmask) == v->uv_subnet &&
532 ((v->uv_subnetmask == 0xffffffff) ||
533 (src != v->uv_subnetbcast)))
534 @@ -1666,6 +1671,10 @@
535 scaletime(now - v->uv_querier->al_ctime),
536 scaletime(v->uv_querier->al_timer));
538 + if (0 != v->uv_ptp_addr) {
539 + fprintf(fp, " PtP remote: %-18s\n",
540 + inet_fmt(v->uv_ptp_addr, s1, sizeof(s1)));
542 if (v->uv_flags & VIFF_BLASTER)
543 fprintf(fp, " blasterbuf size: %dk\n",
544 v->uv_blasterlen / 1024);
545 diff -ur --exclude='*.o' --exclude=cfparse.c --exclude='*~' mrouted-3.9.5/vif.h mrouted-3.9.5-pl/vif.h
546 --- mrouted-3.9.5/vif.h 2011-03-05 21:45:25.000000000 +0100
547 +++ mrouted-3.9.5-pl/vif.h 2011-08-29 14:35:35.695829000 +0200
549 u_int32 uv_lcl_addr; /* local address of this vif */
550 u_int32 uv_rmt_addr; /* remote end-point addr (tunnels only) */
551 u_int32 uv_dst_addr; /* destination for DVMRP/PIM messages */
552 + u_int32 uv_ptp_addr; /* remote peer address (pointopoint only) */
553 u_int32 uv_subnet; /* subnet number (phyints only) */
554 u_int32 uv_subnetmask; /* subnet mask (phyints only) */
555 u_int32 uv_subnetbcast;/* subnet broadcast addr (phyints only) */