Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/rtadvd rtadvd: Remove router renumbering - it's bee...
details: https://anonhg.NetBSD.org/src/rev/c9020b6a0a71
branches: trunk
changeset: 1009347:c9020b6a0a71
user: roy <roy%NetBSD.org@localhost>
date: Tue Apr 21 12:05:54 2020 +0000
description:
rtadvd: Remove router renumbering - it's been disable for years
diffstat:
usr.sbin/rtadvd/Makefile | 4 +-
usr.sbin/rtadvd/rrenum.c | 493 -----------------------------------------------
usr.sbin/rtadvd/rrenum.h | 34 ---
usr.sbin/rtadvd/rtadvd.8 | 26 +--
usr.sbin/rtadvd/rtadvd.c | 61 +-----
5 files changed, 7 insertions(+), 611 deletions(-)
diffs (truncated from 736 to 300 lines):
diff -r 0b41f7b552ad -r c9020b6a0a71 usr.sbin/rtadvd/Makefile
--- a/usr.sbin/rtadvd/Makefile Tue Apr 21 11:35:02 2020 +0000
+++ b/usr.sbin/rtadvd/Makefile Tue Apr 21 12:05:54 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.23 2019/10/13 07:28:21 mrg Exp $
+# $NetBSD: Makefile,v 1.24 2020/04/21 12:05:54 roy Exp $
WARNS?= 4
@@ -7,7 +7,7 @@
USE_FORT?= yes # network server
RUMPPRG= rtadvd
-SRCS= rtadvd.c rrenum.c advcap.c if.c config.c timer.c dump.c
+SRCS= rtadvd.c advcap.c if.c config.c timer.c dump.c
MAN= rtadvd.8 rtadvd.conf.5
CPPFLAGS+= -DINET6
diff -r 0b41f7b552ad -r c9020b6a0a71 usr.sbin/rtadvd/rrenum.c
--- a/usr.sbin/rtadvd/rrenum.c Tue Apr 21 11:35:02 2020 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,493 +0,0 @@
-/* $NetBSD: rrenum.c,v 1.21 2018/04/20 10:26:34 roy Exp $ */
-/* $KAME: rrenum.c,v 1.14 2004/06/14 05:36:00 itojun Exp $ */
-
-/*
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/sysctl.h>
-
-#include <net/if.h>
-#ifdef __FreeBSD__
-#include <net/if_var.h>
-#endif
-#include <net/route.h>
-#include <netinet/in.h>
-#include <netinet/in_var.h>
-#include <netinet/icmp6.h>
-
-#include <arpa/inet.h>
-
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <syslog.h>
-#include "rtadvd.h"
-#include "rrenum.h"
-#include "if.h"
-#include "logit.h"
-#include "prog_ops.h"
-
-#define RR_ISSET_SEGNUM(segnum_bits, segnum) \
- ((((segnum_bits)[(segnum) >> 5]) & (1 << ((segnum) & 31))) != 0)
-#define RR_SET_SEGNUM(segnum_bits, segnum) \
- (((segnum_bits)[(segnum) >> 5]) |= (1 << ((segnum) & 31)))
-
-struct rr_operation {
- u_long rro_seqnum;
- u_long rro_segnum_bits[8];
-};
-
-static struct rr_operation rro;
-static int rr_rcvifindex;
-static int rrcmd2pco[RPM_PCO_MAX] = {
- 0,
- SIOCAIFPREFIX_IN6,
- SIOCCIFPREFIX_IN6,
- SIOCSGIFPREFIX_IN6
-};
-static int s = -1;
-
-/*
- * Check validity of a Prefix Control Operation(PCO).
- * Return 0 on success, 1 on failure.
- */
-static int
-rr_pco_check(int len, struct rr_pco_match *rpm)
-{
- struct rr_pco_use *rpu, *rpulim;
- int checklen;
-
- /* rpm->rpm_len must be (4N * 3) as router-renum-05.txt */
- if ((rpm->rpm_len - 3) < 0 || /* must be at least 3 */
- (rpm->rpm_len - 3) & 0x3) { /* must be multiple of 4 */
- logit(LOG_WARNING, "<%s> rpm_len %d is not 4N * 3",
- __func__, rpm->rpm_len);
- return 1;
- }
- /* rpm->rpm_code must be valid value */
- switch (rpm->rpm_code) {
- case RPM_PCO_ADD:
- case RPM_PCO_CHANGE:
- case RPM_PCO_SETGLOBAL:
- break;
- default:
- logit(LOG_WARNING, "<%s> unknown rpm_code %d", __func__,
- rpm->rpm_code);
- return 1;
- }
- /* rpm->rpm_matchlen must be 0 to 128 inclusive */
- if (rpm->rpm_matchlen > 128) {
- logit(LOG_WARNING, "<%s> rpm_matchlen %d is over 128",
- __func__, rpm->rpm_matchlen);
- return 1;
- }
-
- /*
- * rpu->rpu_uselen, rpu->rpu_keeplen, and sum of them must be
- * between 0 and 128 inclusive
- */
- for (rpu = (struct rr_pco_use *)(rpm + 1),
- rpulim = (struct rr_pco_use *)((char *)rpm + len);
- rpu < rpulim;
- rpu += 1) {
- checklen = rpu->rpu_uselen;
- checklen += rpu->rpu_keeplen;
- /*
- * omit these check, because either of rpu_uselen
- * and rpu_keeplen is unsigned char
- * (128 > rpu_uselen > 0)
- * (128 > rpu_keeplen > 0)
- * (rpu_uselen + rpu_keeplen > 0)
- */
- if (checklen > 128) {
- logit(LOG_WARNING, "<%s> sum of rpu_uselen %d and"
- " rpu_keeplen %d is %d(over 128)",
- __func__, rpu->rpu_uselen,
- rpu->rpu_keeplen,
- rpu->rpu_uselen + rpu->rpu_keeplen);
- return 1;
- }
- }
- return 0;
-}
-
-static void
-do_use_prefix(int len, struct rr_pco_match *rpm,
- struct in6_rrenumreq *irr, int ifindex)
-{
- struct rr_pco_use *rpu, *rpulim;
- struct rainfo *rai;
- struct prefix *pp;
- struct in6_addr rpm_prefix, rpu_prefix;
-
- rpu = (struct rr_pco_use *)(rpm + 1);
- rpulim = (struct rr_pco_use *)((char *)rpm + len);
-
- if (rpu == rpulim) { /* no use prefix */
- if (rpm->rpm_code == RPM_PCO_ADD)
- return;
-
- irr->irr_u_uselen = 0;
- irr->irr_u_keeplen = 0;
- irr->irr_raf_mask_onlink = 0;
- irr->irr_raf_mask_auto = 0;
- irr->irr_vltime = 0;
- irr->irr_pltime = 0;
- memset(&irr->irr_flags, 0, sizeof(irr->irr_flags));
- irr->irr_useprefix.sin6_len = 0; /* let it mean, no addition */
- irr->irr_useprefix.sin6_family = 0;
- irr->irr_useprefix.sin6_addr = in6addr_any;
- if (prog_ioctl(s, rrcmd2pco[rpm->rpm_code], irr) < 0 &&
- errno != EADDRNOTAVAIL)
- logit(LOG_ERR, "<%s> ioctl: %m", __func__);
- return;
- }
-
- for (rpu = (struct rr_pco_use *)(rpm + 1),
- rpulim = (struct rr_pco_use *)((char *)rpm + len);
- rpu < rpulim;
- rpu += 1) {
- /* init in6_rrenumreq fields */
- irr->irr_u_uselen = rpu->rpu_uselen;
- irr->irr_u_keeplen = rpu->rpu_keeplen;
- irr->irr_raf_mask_onlink =
- !!(rpu->rpu_ramask & ICMP6_RR_PCOUSE_RAFLAGS_ONLINK);
- irr->irr_raf_mask_auto =
- !!(rpu->rpu_ramask & ICMP6_RR_PCOUSE_RAFLAGS_AUTO);
- irr->irr_vltime = ntohl(rpu->rpu_vltime);
- irr->irr_pltime = ntohl(rpu->rpu_pltime);
- irr->irr_raf_onlink =
- (rpu->rpu_raflags & ICMP6_RR_PCOUSE_RAFLAGS_ONLINK) == 0 ? 0 : 1;
- irr->irr_raf_auto =
- (rpu->rpu_raflags & ICMP6_RR_PCOUSE_RAFLAGS_AUTO) == 0 ? 0 : 1;
- irr->irr_rrf_decrvalid =
- (rpu->rpu_flags & ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME) == 0 ? 0 : 1;
- irr->irr_rrf_decrprefd =
- (rpu->rpu_flags & ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME) == 0 ? 0 : 1;
- irr->irr_useprefix.sin6_len = sizeof(irr->irr_useprefix);
- irr->irr_useprefix.sin6_family = AF_INET6;
- irr->irr_useprefix.sin6_addr = rpu->rpu_prefix;
-
- if (prog_ioctl(s, rrcmd2pco[rpm->rpm_code], irr) < 0 &&
- errno != EADDRNOTAVAIL)
- logit(LOG_ERR, "<%s> ioctl: %m", __func__);
-
- /* very adhoc: should be rewritten */
- memcpy(&rpm_prefix, &rpm->rpm_prefix, sizeof(rpm_prefix));
- memcpy(&rpu_prefix, &rpu->rpu_prefix, sizeof(rpu_prefix));
- if (rpm->rpm_code == RPM_PCO_CHANGE &&
- IN6_ARE_ADDR_EQUAL(&rpm_prefix, &rpu_prefix) &&
- rpm->rpm_matchlen == rpu->rpu_uselen &&
- rpu->rpu_uselen == rpu->rpu_keeplen) {
- if ((rai = if_indextorainfo(ifindex)) == NULL)
- continue; /* non-advertising IF */
-
- TAILQ_FOREACH(pp, &rai->prefix, next) {
- struct timespec now;
-
- if (prefix_match(&pp->prefix, pp->prefixlen,
- &rpm_prefix,
- rpm->rpm_matchlen)) {
- /* change parameters */
- pp->validlifetime = ntohl(rpu->rpu_vltime);
- pp->preflifetime = ntohl(rpu->rpu_pltime);
- if (irr->irr_rrf_decrvalid) {
- prog_clock_gettime(CLOCK_MONOTONIC,
- &now);
- pp->vltimeexpire =
- now.tv_sec + pp->validlifetime;
- } else
- pp->vltimeexpire = 0;
- if (irr->irr_rrf_decrprefd) {
- prog_clock_gettime(CLOCK_MONOTONIC,
- &now);
- pp->pltimeexpire =
- now.tv_sec + pp->preflifetime;
- } else
- pp->pltimeexpire = 0;
- }
- }
- }
- }
-}
-
-/*
- * process a Prefix Control Operation(PCO).
- * return 0 on success, 1 on failure
- */
-static int
-do_pco(struct icmp6_router_renum *rr, int len, struct rr_pco_match *rpm)
-{
- int ifindex = 0;
- struct in6_rrenumreq irr;
- struct rainfo *rai;
-
- if ((rr_pco_check(len, rpm) != 0))
- return 1;
-
- if (s == -1 && (s = prog_socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
- logit(LOG_ERR, "<%s> socket: %m", __func__);
- exit(1);
- }
-
- memset(&irr, 0, sizeof(irr));
- irr.irr_origin = PR_ORIG_RR;
- irr.irr_m_len = rpm->rpm_matchlen;
- irr.irr_m_minlen = rpm->rpm_minlen;
- irr.irr_m_maxlen = rpm->rpm_maxlen;
- irr.irr_matchprefix.sin6_len = sizeof(irr.irr_matchprefix);
- irr.irr_matchprefix.sin6_family = AF_INET6;
- irr.irr_matchprefix.sin6_addr = rpm->rpm_prefix;
-
- /*
- * if ICMP6_RR_FLAGS_FORCEAPPLY(A flag) is 0 and IFF_UP is off,
- * the interface is not applied
- */
-
- if (rr->rr_flags & ICMP6_RR_FLAGS_FORCEAPPLY) {
- while (if_indextoname(++ifindex, irr.irr_name)) {
- rai = if_indextorainfo(ifindex);
Home |
Main Index |
Thread Index |
Old Index