View | Details | Raw Unified | Return to bug 144343 | Differences between
and this patch

Collapse All | Expand All

(-)usr.sbin/rtadvd/config.c (+55 lines)
Lines 280-285 Link Here
280
rm_rainfo(struct rainfo *rai)
280
rm_rainfo(struct rainfo *rai)
281
{
281
{
282
	struct prefix *pfx;
282
	struct prefix *pfx;
283
	struct ignore_prefix *ipfx;
283
	struct soliciter *sol;
284
	struct soliciter *sol;
284
	struct rdnss *rdn;
285
	struct rdnss *rdn;
285
	struct rdnss_addr *rdna;
286
	struct rdnss_addr *rdna;
Lines 298-303 Link Here
298
299
299
	while ((pfx = TAILQ_FIRST(&rai->rai_prefix)) != NULL)
300
	while ((pfx = TAILQ_FIRST(&rai->rai_prefix)) != NULL)
300
		delete_prefix(pfx);
301
		delete_prefix(pfx);
302
	while ((ipfx = TAILQ_FIRST(&rai->rai_ignore_prefix)) != NULL) {
303
		TAILQ_REMOVE(&rai->rai_ignore_prefix, ipfx, ipfx_next);
304
		free(ipfx);
305
	}
301
	while ((sol = TAILQ_FIRST(&rai->rai_soliciter)) != NULL) {
306
	while ((sol = TAILQ_FIRST(&rai->rai_soliciter)) != NULL) {
302
		TAILQ_REMOVE(&rai->rai_soliciter, sol, sol_next);
307
		TAILQ_REMOVE(&rai->rai_soliciter, sol, sol_next);
303
		free(sol);
308
		free(sol);
Lines 359-364 Link Here
359
364
360
	ELM_MALLOC(rai, exit(1));
365
	ELM_MALLOC(rai, exit(1));
361
	TAILQ_INIT(&rai->rai_prefix);
366
	TAILQ_INIT(&rai->rai_prefix);
367
	TAILQ_INIT(&rai->rai_ignore_prefix);
362
	TAILQ_INIT(&rai->rai_route);
368
	TAILQ_INIT(&rai->rai_route);
363
	TAILQ_INIT(&rai->rai_rdnss);
369
	TAILQ_INIT(&rai->rai_rdnss);
364
	TAILQ_INIT(&rai->rai_dnssl);
370
	TAILQ_INIT(&rai->rai_dnssl);
Lines 491-496 Link Here
491
	MAYHAVE(val, "clockskew", 0);
497
	MAYHAVE(val, "clockskew", 0);
492
	rai->rai_clockskew = val;
498
	rai->rai_clockskew = val;
493
499
500
	/* list of prefixes not advertised */
501
	rai->rai_ignore_pfxs = 0;
502
	for (i = -1; i < MAXPREFIX; i++) {
503
		struct ignore_prefix *ipfx;
504
505
		makeentry(entbuf, sizeof(entbuf), i, "ignoreaddr");
506
		addr = (char *)agetstr(entbuf, &bp);
507
		if (addr == NULL)
508
			continue;
509
510
		/* allocate memory to store prefix information */
511
		ELM_MALLOC(ipfx, exit(1));
512
		ipfx->ipfx_rainfo = rai;
513
514
		if (inet_pton(AF_INET6, addr, &ipfx->ipfx_prefix) != 1) {
515
			syslog(LOG_ERR,
516
			    "<%s> inet_pton failed for %s",
517
			    __func__, addr);
518
			goto getconfig_free_ignore_pfx;
519
		}
520
521
		makeentry(entbuf, sizeof(entbuf), i, "ignoreplen");
522
		MAYHAVE(val, entbuf, 64);
523
		if (val < 0 || val > 128) {
524
			syslog(LOG_ERR, "<%s> prefixlen (%" PRIu32 ") for %s "
525
			    "on %s out of range",
526
			    __func__, val, addr, ifi->ifi_ifname);
527
			goto getconfig_free_ignore_pfx;
528
		}
529
		ipfx->ipfx_prefixlen = (int)val;
530
531
		/* link into chain */
532
		TAILQ_INSERT_TAIL(&rai->rai_ignore_prefix, ipfx, ipfx_next);
533
		rai->rai_ignore_pfxs++;
534
		continue;
535
getconfig_free_ignore_pfx:
536
		free(ipfx);
537
	}
538
494
	rai->rai_pfxs = 0;
539
	rai->rai_pfxs = 0;
495
	for (i = -1; i < MAXPREFIX; i++) {
540
	for (i = -1; i < MAXPREFIX; i++) {
496
		struct prefix *pfx;
541
		struct prefix *pfx;
Lines 1046-1051 Link Here
1046
		}
1091
		}
1047
		if (plen == 128)	/* XXX */
1092
		if (plen == 128)	/* XXX */
1048
			continue;
1093
			continue;
1094
		if (find_ignore_prefix(rai, a, plen) != NULL) {
1095
			/* ignore a prefix configured to be ignored. */
1096
			syslog(LOG_DEBUG, "<%s> new prefix (%s/%d) "
1097
			    "is configured to be ignored on %s",
1098
			    __func__,
1099
			    inet_ntop(AF_INET6, a,
1100
			        (char *)ntopbuf, sizeof(ntopbuf)),
1101
			    plen, ifi->ifi_ifname);
1102
			continue;
1103
		}
1049
		if (find_prefix(rai, a, plen)) {
1104
		if (find_prefix(rai, a, plen)) {
1050
			/* ignore a duplicated prefix. */
1105
			/* ignore a duplicated prefix. */
1051
			continue;
1106
			continue;
(-)usr.sbin/rtadvd/rtadvd.c (+27 lines)
Lines 605-610 Link Here
605
				    __func__, plen);
605
				    __func__, plen);
606
				break;
606
				break;
607
			}
607
			}
608
			/* prefix configured to be ignored */
609
			if (find_ignore_prefix(rai, addr, plen) != NULL) {
610
				syslog(LOG_DEBUG, "<%s> new prefix (%s/%d) "
611
				    "is configured to be ignored on %s",
612
				    __func__,
613
				    inet_ntop(AF_INET6, addr,
614
				    	(char *)addrbuf, sizeof(addrbuf)),
615
				    plen, ifi->ifi_ifname);
616
				break;
617
			}
608
			pfx = find_prefix(rai, addr, plen);
618
			pfx = find_prefix(rai, addr, plen);
609
			if (pfx) {
619
			if (pfx) {
610
				if (pfx->pfx_timer) {
620
				if (pfx->pfx_timer) {
Lines 1402-1407 Link Here
1402
	return (0);
1412
	return (0);
1403
}
1413
}
1404
1414
1415
struct ignore_prefix *
1416
find_ignore_prefix(struct rainfo *rai, struct in6_addr *prefix, int plen)
1417
{
1418
	struct ignore_prefix *ipfx;
1419
	int bytelen, bitlen;
1420
	char bitmask;
1421
1422
	TAILQ_FOREACH(ipfx, &rai->rai_ignore_prefix, ipfx_next) {
1423
		if (prefix_match(prefix, plen,
1424
		    &ipfx->ipfx_prefix, ipfx->ipfx_prefixlen)) {
1425
			return ipfx;
1426
		}
1427
	}
1428
1429
	return (NULL);
1430
}
1431
1405
static int
1432
static int
1406
nd6_options(struct nd_opt_hdr *hdr, int limit,
1433
nd6_options(struct nd_opt_hdr *hdr, int limit,
1407
	union nd_opt *ndopts, uint32_t optflags)
1434
	union nd_opt *ndopts, uint32_t optflags)
(-)usr.sbin/rtadvd/rtadvd.h (+13 lines)
Lines 178-183 Link Here
178
	struct sockaddr_in6	sol_addr;
178
	struct sockaddr_in6	sol_addr;
179
};
179
};
180
180
181
struct ignore_prefix {
182
	TAILQ_ENTRY(ignore_prefix)	ipfx_next;
183
	struct rainfo	*ipfx_rainfo;	/* back pointer to the interface */
184
	int		ipfx_prefixlen;
185
	struct in6_addr	ipfx_prefix;
186
};
187
181
struct	rainfo {
188
struct	rainfo {
182
	/* pointer for list */
189
	/* pointer for list */
183
	TAILQ_ENTRY(rainfo)	rai_next;
190
	TAILQ_ENTRY(rainfo)	rai_next;
Lines 204-209 Link Here
204
	TAILQ_HEAD(, prefix) rai_prefix;/* AdvPrefixList(link head) */
211
	TAILQ_HEAD(, prefix) rai_prefix;/* AdvPrefixList(link head) */
205
	int	rai_pfxs;		/* number of prefixes */
212
	int	rai_pfxs;		/* number of prefixes */
206
213
214
	/* list of prefixes not advertised */
215
	TAILQ_HEAD(, ignore_prefix)	rai_ignore_prefix;	/* prefix list */
216
	int	rai_ignore_pfxs;	/* number of prefixes */
217
207
	uint16_t	rai_clockskew;	/* used for consisitency check of lifetimes */
218
	uint16_t	rai_clockskew;	/* used for consisitency check of lifetimes */
208
219
209
	TAILQ_HEAD(, rdnss) rai_rdnss;	/* DNS server list */
220
	TAILQ_HEAD(, rdnss) rai_rdnss;	/* DNS server list */
Lines 294-298 Link Here
294
struct ifinfo		*if_indextoifinfo(int);
305
struct ifinfo		*if_indextoifinfo(int);
295
struct prefix		*find_prefix(struct rainfo *,
306
struct prefix		*find_prefix(struct rainfo *,
296
			    struct in6_addr *, int);
307
			    struct in6_addr *, int);
308
struct ignore_prefix	*find_ignore_prefix(struct rainfo *,
309
			    struct in6_addr *, int);
297
void			rtadvd_set_reload(int);
310
void			rtadvd_set_reload(int);
298
void			rtadvd_set_shutdown(int);
311
void			rtadvd_set_shutdown(int);

Return to bug 144343