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 disabled use of SIOCGIFPREFIX...



details:   https://anonhg.NetBSD.org/src/rev/7f955fb14994
branches:  trunk
changeset: 1009348:7f955fb14994
user:      roy <roy%NetBSD.org@localhost>
date:      Tue Apr 21 12:16:47 2020 +0000

description:
rtadvd: Remove disabled use of SIOCGIFPREFIX_IN6

It's not been enabled since the functionality was added to ifconfig(8)
many many years ago.

diffstat:

 usr.sbin/rtadvd/config.c |  137 +++++++++++-----------------------------------
 usr.sbin/rtadvd/config.h |    4 +-
 usr.sbin/rtadvd/rtadvd.c |    4 +-
 3 files changed, 37 insertions(+), 108 deletions(-)

diffs (201 lines):

diff -r c9020b6a0a71 -r 7f955fb14994 usr.sbin/rtadvd/config.c
--- a/usr.sbin/rtadvd/config.c  Tue Apr 21 12:05:54 2020 +0000
+++ b/usr.sbin/rtadvd/config.c  Tue Apr 21 12:16:47 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: config.c,v 1.43 2019/11/11 13:42:49 roy Exp $  */
+/*     $NetBSD: config.c,v 1.44 2020/04/21 12:16:47 roy Exp $  */
 /*     $KAME: config.c,v 1.93 2005/10/17 14:40:02 suz Exp $    */
 
 /*
@@ -875,49 +875,6 @@
 }
 
 /*
- * Add a prefix to the list of specified interface and reconstruct
- * the outgoing packet.
- * The prefix must not be in the list.
- * XXX: other parameters of the prefix(e.g. lifetime) should be
- * able to be specified.
- */
-static void
-add_prefix(struct rainfo *rai, struct in6_prefixreq *ipr)
-{
-       struct prefix *prefix;
-       char ntopbuf[INET6_ADDRSTRLEN];
-
-       if ((prefix = calloc(1, sizeof(*prefix))) == NULL) {
-               logit(LOG_ERR, "<%s> memory allocation failed",
-                      __func__);
-               return;         /* XXX: error or exit? */
-       }
-       prefix->prefix = ipr->ipr_prefix.sin6_addr;
-       prefix->prefixlen = ipr->ipr_plen;
-       prefix->validlifetime = ipr->ipr_vltime;
-       prefix->preflifetime = ipr->ipr_pltime;
-       prefix->onlinkflg = ipr->ipr_raf_onlink;
-       prefix->autoconfflg = ipr->ipr_raf_auto;
-       prefix->origin = PREFIX_FROM_DYNAMIC;
-
-       prefix->rainfo = rai;
-       TAILQ_INSERT_TAIL(&rai->prefix, prefix, next);
-       rai->pfxs++;
-
-       logit(LOG_DEBUG, "<%s> new prefix %s/%d was added on %s",
-              __func__, inet_ntop(AF_INET6, &ipr->ipr_prefix.sin6_addr,
-                                      ntopbuf, INET6_ADDRSTRLEN),
-              ipr->ipr_plen, rai->ifname);
-
-       /* free the previous packet */
-       free(rai->ra_data);
-       rai->ra_data = NULL;
-
-       /* reconstruct the packet */
-       make_packet(rai);
-}
-
-/*
  * Delete a prefix to the list of specified interface and reconstruct
  * the outgoing packet.
  * The prefix must be in the list.
@@ -1001,73 +958,45 @@
 }
 
 /*
- * Try to get an in6_prefixreq contents for a prefix which matches
- * ipr->ipr_prefix and ipr->ipr_plen and belongs to
- * the interface whose name is ipr->ipr_name[].
+ * Add a prefix to the list of specified interface and reconstruct
+ * the outgoing packet.
+ * The prefix must not be in the list.
+ * XXX: other parameters of the prefix(e.g. lifetime) should be
+ * able to be specified.
  */
-static int
-init_prefix(struct in6_prefixreq *ipr)
+void
+add_prefix(struct rainfo *rai, int ifindex, struct in6_addr *addr, int plen)
 {
-#if 0
-       int s;
-
-       if ((s = prog_socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
-               logit(LOG_ERR, "<%s> socket: %m", __func__);
-               exit(1);
-       }
-
-       if (prog_ioctl(s, SIOCGIFPREFIX_IN6, ipr) < 0) {
-               logit(LOG_INFO, "<%s> ioctl:SIOCGIFPREFIX: %m", __func__);
-
-               ipr->ipr_vltime = DEF_ADVVALIDLIFETIME;
-               ipr->ipr_pltime = DEF_ADVPREFERREDLIFETIME;
-               ipr->ipr_raf_onlink = 1;
-               ipr->ipr_raf_auto = 1;
-               /* omit other field initialization */
-       }
-       else if (ipr->ipr_origin < PR_ORIG_RR) {
-               char ntopbuf[INET6_ADDRSTRLEN];
+       struct prefix *prefix;
+       char ntopbuf[INET6_ADDRSTRLEN];
 
-               logit(LOG_WARNING, "<%s> Added prefix(%s)'s origin %d is"
-                      "lower than PR_ORIG_RR(router renumbering)."
-                      "This should not happen if I am router", __func__,
-                      inet_ntop(AF_INET6, &ipr->ipr_prefix.sin6_addr, ntopbuf,
-                                sizeof(ntopbuf)), ipr->ipr_origin);
-               prog_close(s);
-               return 1;
+       if ((prefix = calloc(1, sizeof(*prefix))) == NULL) {
+               logit(LOG_ERR, "<%s> memory allocation failed",
+                      __func__);
+               return;         /* XXX: error or exit? */
        }
-
-       prog_close(s);
-       return 0;
-#else
-       ipr->ipr_vltime = DEF_ADVVALIDLIFETIME;
-       ipr->ipr_pltime = DEF_ADVPREFERREDLIFETIME;
-       ipr->ipr_raf_onlink = 1;
-       ipr->ipr_raf_auto = 1;
-       return 0;
-#endif
-}
+       prefix->prefix = *addr;
+       prefix->prefixlen = plen;
+       prefix->validlifetime = DEF_ADVVALIDLIFETIME;
+       prefix->preflifetime = DEF_ADVPREFERREDLIFETIME;
+       prefix->onlinkflg = 1;
+       prefix->autoconfflg = 0;
+       prefix->origin = PREFIX_FROM_DYNAMIC;
 
-void
-make_prefix(struct rainfo *rai, int ifindex, struct in6_addr *addr, int plen)
-{
-       struct in6_prefixreq ipr;
+       prefix->rainfo = rai;
+       TAILQ_INSERT_TAIL(&rai->prefix, prefix, next);
+       rai->pfxs++;
 
-       memset(&ipr, 0, sizeof(ipr));
-       if (if_indextoname(ifindex, ipr.ipr_name) == NULL) {
-               logit(LOG_ERR, "<%s> Prefix added interface No.%d doesn't"
-                      "exist. This should not happen: %m", __func__,
-                      ifindex);
-               exit(1);
-       }
-       ipr.ipr_prefix.sin6_len = sizeof(ipr.ipr_prefix);
-       ipr.ipr_prefix.sin6_family = AF_INET6;
-       ipr.ipr_prefix.sin6_addr = *addr;
-       ipr.ipr_plen = plen;
+       logit(LOG_DEBUG, "<%s> new prefix %s/%d was added on %s",
+              __func__, inet_ntop(AF_INET6, addr, ntopbuf, INET6_ADDRSTRLEN),
+              plen, rai->ifname);
 
-       if (init_prefix(&ipr))
-               return; /* init failed by some error */
-       add_prefix(rai, &ipr);
+       /* free the previous packet */
+       free(rai->ra_data);
+       rai->ra_data = NULL;
+
+       /* reconstruct the packet */
+       make_packet(rai);
 }
 
 void
diff -r c9020b6a0a71 -r 7f955fb14994 usr.sbin/rtadvd/config.h
--- a/usr.sbin/rtadvd/config.h  Tue Apr 21 12:05:54 2020 +0000
+++ b/usr.sbin/rtadvd/config.h  Tue Apr 21 12:16:47 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: config.h,v 1.10 2018/04/20 10:39:37 roy Exp $  */
+/*     $NetBSD: config.h,v 1.11 2020/04/21 12:16:47 roy Exp $  */
 /*     $KAME: config.h,v 1.9 2003/08/06 04:19:40 ono Exp $     */
 
 /*
@@ -35,7 +35,7 @@
 extern void delete_prefix(struct prefix *);
 extern void invalidate_prefix(struct prefix *);
 extern void update_prefix(struct prefix *);
-extern void make_prefix(struct rainfo *, int, struct in6_addr *, int);
+extern void add_prefix(struct rainfo *, int, struct in6_addr *, int);
 extern void make_packet(struct rainfo *);
 extern void get_prefix(struct rainfo *);
 
diff -r c9020b6a0a71 -r 7f955fb14994 usr.sbin/rtadvd/rtadvd.c
--- a/usr.sbin/rtadvd/rtadvd.c  Tue Apr 21 12:05:54 2020 +0000
+++ b/usr.sbin/rtadvd/rtadvd.c  Tue Apr 21 12:16:47 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtadvd.c,v 1.72 2020/04/21 12:05:54 roy Exp $  */
+/*     $NetBSD: rtadvd.c,v 1.73 2020/04/21 12:16:47 roy Exp $  */
 /*     $KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $    */
 
 /*
@@ -615,7 +615,7 @@
                                }
                                break;
                        }
-                       make_prefix(rai, ifindex, addr, plen);
+                       add_prefix(rai, ifindex, addr, plen);
                        prefixchange = 1;
                        break;
                case RTM_DELETE:



Home | Main Index | Thread Index | Old Index