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;
12 + } else if (flags & IFF_BROADCAST) {
13 + /* getifaddr doesn't give us the p2p link in this case */
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-30 15:30:10.508700000 +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,50 @@
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 + /* Send to PlanetLab's user-space MRT daemon */
290 + op.op = MRT_ADD_MFC;
291 + op.len = sizeof(op.mc);
292 + if (send(plrt_socket, &op, sizeof(op), 0) < 0)
294 +#else /* here if not PLANETLAB */
296 /* write to kernel space */
297 if (setsockopt(igmp_socket, IPPROTO_IP, MRT_ADD_MFC,
298 - (char *)&mc, sizeof(mc)) < 0) {
299 + (char *)&op.mc, sizeof(op.mc)) < 0)
301 +#endif /* PLANETLAB */
305 md_log(MD_ADD_FAIL, origin, g->gt_mcastgrp);
307 logit(LOG_WARNING, errno, "setsockopt MRT_ADD_MFC",
308 inet_fmt(origin, s1, sizeof(s1)), inet_fmt(g->gt_mcastgrp, s2, sizeof(s2)));
314 @@ -271,20 +361,37 @@
316 int k_del_rg(u_int32 origin, struct gtable *g)
326 md_log(MD_DEL, origin, g->gt_mcastgrp);
328 /* copy table values so that setsockopt can process it */
329 - mc.mfcc_origin.s_addr = origin;
330 + op.mc.mfcc_origin.s_addr = origin;
332 - mc.mfcc_originmask.s_addr = 0xffffffff;
333 + op.mc.mfcc_originmask.s_addr = 0xffffffff;
335 - mc.mfcc_mcastgrp.s_addr = g->gt_mcastgrp;
336 + op.mc.mfcc_mcastgrp.s_addr = g->gt_mcastgrp;
340 + /* Send to PlanetLab's user-space MRT daemon */
341 + op.op = MRT_DEL_MFC;
342 + op.len = sizeof(op.mc);
343 + if (send(plrt_socket, &op, sizeof(op), 0) < 0)
345 +#else /* here if not PLANETLAB */
347 /* write to kernel space */
348 - if (setsockopt(igmp_socket, IPPROTO_IP, MRT_DEL_MFC, (char *)&mc, sizeof(mc)) < 0) {
349 + if (setsockopt(igmp_socket, IPPROTO_IP, MRT_DEL_MFC, (char *)&op.mc, sizeof(op.mc)) < 0)
351 +#endif /* PLANETLAB */
355 md_log(MD_DEL_FAIL, origin, g->gt_mcastgrp);
357 diff -ur --exclude='*.o' --exclude=cfparse.c --exclude='*~' mrouted-3.9.5/main.c mrouted-3.9.5-pl/main.c
358 --- mrouted-3.9.5/main.c 2011-03-05 21:45:25.000000000 +0100
359 +++ mrouted-3.9.5-pl/main.c 2011-08-30 15:31:01.281814000 +0200
361 time_t mrouted_init_time;
364 -#define NHANDLERS 34
365 +#define NHANDLERS 35
371 static struct ihandler {
373 fputs(" -h, --help Show this help text\n", stderr);
374 fputs(" -p Disable pruning. Deprecated, compatibility option\n", stderr);
375 fputs(" -r, --show-routes Show state of VIFs and multicast routing tables\n", stderr);
377 + fputs(" -F Path to the PlanetLab userland forwarder, default /var/run/mcastfwd\n", stderr);
379 fprintf(stderr, " -v, --version Show %s version\n", __progname);
382 @@ -258,11 +261,23 @@
384 snprintf(versionstring, sizeof(versionstring), "mrouted version %s", todaysversion);
386 - while ((ch = getopt_long(argc, argv, "c:d::fhpP::rv", long_options, NULL)) != EOF) {
388 +#define PLOPTIONS ":F"
390 +#define PLOPTIONS ""
393 + while ((ch = getopt_long(argc, argv, "c:d::fhpP::rv" PLOPTIONS, long_options, NULL)) != EOF) {
396 configfilename = optarg;
401 + plrt_socket_path = optarg;
415 * Unfortunately, you can't k_get_version() unless you've
418 vers = k_get_version();
422 * This function must change whenever the kernel version changes
425 logit(LOG_ERR, 0, "Descriptor too big");
426 FD_SET(igmp_socket, &readers);
427 nfds = igmp_socket + 1;
430 + if (plrt_socket >= (int)FD_SETSIZE)
431 + logit(LOG_ERR, 0, "Descriptor too big");
432 + FD_SET(plrt_socket, &readers);
433 + if (plrt_socket >= nfds)
434 + nfds = plrt_socket + 1;
437 for (i = 0; i < nhandlers; i++) {
438 if (ihandlers[i].fd >= (int)FD_SETSIZE)
439 logit(LOG_ERR, 0, "Descriptor too big");
441 accept_igmp(recvlen);
445 + if (FD_ISSET(plrt_socket, &rfds)) {
446 + recvlen = recvfrom(plrt_socket, recv_buf, RECV_BUF_SIZE, 0, NULL, &dummy);
448 + if (errno != EINTR) logit(LOG_ERR, errno, "recvfrom");
451 + accept_igmp(recvlen);
455 for (i = 0; i < nhandlers; i++) {
456 if (FD_ISSET(ihandlers[i].fd, &rfds)) {
457 (*ihandlers[i].func)(ihandlers[i].fd, &rfds);
466 diff -ur --exclude='*.o' --exclude=cfparse.c --exclude='*~' mrouted-3.9.5/Makefile mrouted-3.9.5-pl/Makefile
467 --- mrouted-3.9.5/Makefile 2011-03-05 21:45:25.000000000 +0100
468 +++ mrouted-3.9.5-pl/Makefile 2011-08-10 17:18:22.233596000 +0200
472 CFLAGS = $(MCAST_INCLUDE) $(SNMPDEF) $(RSRRDEF) $(INCLUDES) $(DEFS) $(USERCOMPILE)
473 -CFLAGS += -O2 -W -Wall -Werror
474 +CFLAGS += -O2 -W -Wall
476 LDLIBS = $(SNMPLIBDIR) $(SNMPLIBS) $(EXTRA_LIBS)
477 LDFLAGS += -Wl,-Map,$@.map
478 Only in mrouted-3.9.5-pl: Makefile.bk
479 Only in mrouted-3.9.5-pl: map-mbone
480 Only in mrouted-3.9.5-pl: map-mbone.map
481 Only in mrouted-3.9.5-pl: mrinfo
482 Only in mrouted-3.9.5-pl: mrinfo.map
483 Only in mrouted-3.9.5-pl: mrouted
484 Only in mrouted-3.9.5-pl: mrouted.map
485 Only in mrouted-3.9.5-pl: mtrace
486 Only in mrouted-3.9.5-pl: mtrace.map
487 diff -ur --exclude='*.o' --exclude=cfparse.c --exclude='*~' mrouted-3.9.5/pathnames.h mrouted-3.9.5-pl/pathnames.h
488 --- mrouted-3.9.5/pathnames.h 2011-03-05 21:45:25.000000000 +0100
489 +++ mrouted-3.9.5-pl/pathnames.h 2011-08-29 13:10:27.043684000 +0200
491 #define _PATH_MROUTED_GENID _PATH_MROUTED_RUNDIR "/mrouted.genid"
492 #define _PATH_MROUTED_DUMP _PATH_MROUTED_RUNDIR "/mrouted.dump"
493 #define _PATH_MROUTED_CACHE _PATH_MROUTED_RUNDIR "/mrouted.cache"
494 +#define _PATH_MROUTED_PLRT _PATH_VARRUN "mcastrt"
496 #endif /* __MROUTED_PATHNAMES_H__ */
497 Only in mrouted-3.9.5-pl: vers.c
498 diff -ur --exclude='*.o' --exclude=cfparse.c --exclude='*~' mrouted-3.9.5/vif.c mrouted-3.9.5-pl/vif.c
499 --- mrouted-3.9.5/vif.c 2011-03-05 21:45:25.000000000 +0100
500 +++ mrouted-3.9.5-pl/vif.c 2011-08-30 10:18:29.223147000 +0200
504 v->uv_dst_addr = t ? 0 : dvmrp_group;
505 + v->uv_ptp_addr = 0;
507 v->uv_subnetmask = 0;
508 v->uv_subnetbcast = 0;
513 + if (src == v->uv_ptp_addr)
515 if ((src & v->uv_subnetmask) == v->uv_subnet &&
516 ((v->uv_subnetmask == 0xffffffff) ||
517 (src != v->uv_subnetbcast)))
518 @@ -1666,6 +1669,10 @@
519 scaletime(now - v->uv_querier->al_ctime),
520 scaletime(v->uv_querier->al_timer));
522 + if (0 != v->uv_ptp_addr) {
523 + fprintf(fp, " PtP remote: %-18s\n",
524 + inet_fmt(v->uv_ptp_addr, s1, sizeof(s1)));
526 if (v->uv_flags & VIFF_BLASTER)
527 fprintf(fp, " blasterbuf size: %dk\n",
528 v->uv_blasterlen / 1024);
529 diff -ur --exclude='*.o' --exclude=cfparse.c --exclude='*~' mrouted-3.9.5/vif.h mrouted-3.9.5-pl/vif.h
530 --- mrouted-3.9.5/vif.h 2011-03-05 21:45:25.000000000 +0100
531 +++ mrouted-3.9.5-pl/vif.h 2011-08-29 14:35:35.695829000 +0200
533 u_int32 uv_lcl_addr; /* local address of this vif */
534 u_int32 uv_rmt_addr; /* remote end-point addr (tunnels only) */
535 u_int32 uv_dst_addr; /* destination for DVMRP/PIM messages */
536 + u_int32 uv_ptp_addr; /* remote peer address (pointopoint only) */
537 u_int32 uv_subnet; /* subnet number (phyints only) */
538 u_int32 uv_subnetmask; /* subnet mask (phyints only) */
539 u_int32 uv_subnetbcast;/* subnet broadcast addr (phyints only) */