Browse Source

zebra: move more ND RA code to rtadv.c

Set generic interface management code free from details of ND RA by
means of two extern functions:

* function interface.c:nd_dump_vty() is now rtadv.c:rtadv_if_dump_vty()
* conditional initialization code formerly belonging to
  interface.c:if_zebra_new_hook() is now rtadv.c:rtadv_if_new_hook()
* struct rtadvconf and definition of RTADV now belong to rtadv.h
* rtadv_pref_strs[] and rtadv_pref_strs_max are now static variables of
  rtadv.c

After that fix "testzebra" build by adding a dependency on rtadv.c and
adding necessary zprivs bits.
Denis Ovsienko 7 years ago
parent
commit
7c55db3ac8
6 changed files with 265 additions and 264 deletions
  1. 3 2
      zebra/Makefile.am
  2. 3 108
      zebra/interface.c
  3. 2 144
      zebra/interface.h
  4. 85 5
      zebra/rtadv.c
  5. 156 5
      zebra/rtadv.h
  6. 16 0
      zebra/test_main.c

+ 3 - 2
zebra/Makefile.am

@@ -44,8 +44,9 @@ zebra_SOURCES = \
 	$(othersrc) $(protobuf_srcs) $(dev_srcs)
 
 testzebra_SOURCES = test_main.c zebra_rib.c interface.c connected.c debug.c \
-	zebra_vty.c \
-	kernel_null.c  redistribute_null.c ioctl_null.c misc_null.c zebra_rnh_null.c
+	zebra_vty.c rtadv.c \
+	kernel_null.c  redistribute_null.c ioctl_null.c misc_null.c \
+	zebra_rnh_null.c
 
 noinst_HEADERS = \
 	connected.h ioctl.h rib.h rt.h zserv.h redistribute.h debug.h rtadv.h \

+ 3 - 108
zebra/interface.c

@@ -30,25 +30,17 @@
 #include "memory.h"
 #include "ioctl.h"
 #include "connected.h"
-#include "log.h"
 #include "zclient.h"
 #include "vrf.h"
 #include "command.h"
 
 #include "zebra/interface.h"
-#include "zebra/rtadv.h"
 #include "zebra/rib.h"
 #include "zebra/zserv.h"
 #include "zebra/redistribute.h"
 #include "zebra/debug.h"
 #include "zebra/irdp.h"
 
-#if defined (HAVE_RTADV)
-/* Order is intentional.  Matches RFC4191.  This array is also used for
-   command matching, so only modify with care. */
-const char *rtadv_pref_strs[] = { "medium", "high", "INVALID", "low", 0 };
-#endif /* HAVE_RTADV */
-
 /* We don't have a tidy top-level instance object for zebra, or interfaces */
 static struct zebra_if_defaults zif_defaults = {
   .linkdetect = IF_LINKDETECT_UNSPEC,
@@ -117,35 +109,9 @@ if_zebra_new_hook (struct interface *ifp)
     }
   
 #if defined (HAVE_RTADV)
-  {
-    /* Set default router advertise values. */
-    struct rtadvconf *rtadv;
-
-    rtadv = &zebra_if->rtadv;
-
-    rtadv->AdvSendAdvertisements = 0;
-    rtadv->MaxRtrAdvInterval = RTADV_MAX_RTR_ADV_INTERVAL;
-    rtadv->MinRtrAdvInterval = RTADV_MIN_RTR_ADV_INTERVAL;
-    rtadv->AdvIntervalTimer = 0;
-    rtadv->AdvManagedFlag = 0;
-    rtadv->AdvOtherConfigFlag = 0;
-    rtadv->AdvHomeAgentFlag = 0;
-    rtadv->AdvLinkMTU = 0;
-    rtadv->AdvReachableTime = 0;
-    rtadv->AdvRetransTimer = 0;
-    rtadv->AdvCurHopLimit = 0;
-    rtadv->AdvDefaultLifetime = -1; /* derive from MaxRtrAdvInterval */
-    rtadv->HomeAgentPreference = 0;
-    rtadv->HomeAgentLifetime = -1; /* derive from AdvDefaultLifetime */
-    rtadv->AdvIntervalOption = 0;
-    rtadv->DefaultPreference = RTADV_PREF_MEDIUM;
-
-    rtadv->AdvPrefixList = list_new ();
-    rtadv->AdvRDNSSList = list_new ();
-    rtadv->AdvDNSSLList = list_new ();
-  }    
+  rtadv_if_new_hook (&zebra_if->rtadv);
 #endif /* HAVE_RTADV */
-
+  
   /* Initialize installed address chains tree. */
   zebra_if->ipv4_subnets = route_table_init ();
 
@@ -747,74 +713,6 @@ connected_dump_vty (struct vty *vty, struct connected *connected)
   vty_out (vty, "%s", VTY_NEWLINE);
 }
 
-#if defined (HAVE_RTADV)
-/* Dump interface ND information to vty. */
-static void
-nd_dump_vty (struct vty *vty, struct interface *ifp)
-{
-  struct zebra_if *zif;
-  struct rtadvconf *rtadv;
-  int interval;
-
-  zif = (struct zebra_if *) ifp->info;
-  rtadv = &zif->rtadv;
-
-  if (rtadv->AdvSendAdvertisements)
-    {
-      vty_out (vty, "  ND advertised reachable time is %d milliseconds%s",
-	       rtadv->AdvReachableTime, VTY_NEWLINE);
-      vty_out (vty, "  ND advertised retransmit interval is %d milliseconds%s",
-	       rtadv->AdvRetransTimer, VTY_NEWLINE);
-      interval = rtadv->MaxRtrAdvInterval;
-      if (interval % 1000)
-        vty_out (vty, "  ND router advertisements are sent every "
-			"%d milliseconds%s", interval,
-		 VTY_NEWLINE);
-      else
-        vty_out (vty, "  ND router advertisements are sent every "
-			"%d seconds%s", interval / 1000,
-		 VTY_NEWLINE);
-      if (rtadv->AdvDefaultLifetime != -1)
-	vty_out (vty, "  ND router advertisements live for %d seconds%s",
-		 rtadv->AdvDefaultLifetime, VTY_NEWLINE);
-      else
-	vty_out (vty, "  ND router advertisements lifetime tracks ra-interval%s",
-		 VTY_NEWLINE);
-      vty_out (vty, "  ND router advertisement default router preference is "
-			"%s%s", rtadv_pref_strs[rtadv->DefaultPreference],
-		 VTY_NEWLINE);
-      if (rtadv->AdvManagedFlag)
-	vty_out (vty, "  Hosts use DHCP to obtain routable addresses.%s",
-		 VTY_NEWLINE);
-      else
-	vty_out (vty, "  Hosts use stateless autoconfig for addresses.%s",
-		 VTY_NEWLINE);
-      if (rtadv->AdvHomeAgentFlag)
-      {
-      	vty_out (vty, "  ND router advertisements with "
-				"Home Agent flag bit set.%s",
-		 VTY_NEWLINE);
-	if (rtadv->HomeAgentLifetime != -1)
-	  vty_out (vty, "  Home Agent lifetime is %u seconds%s",
-	           rtadv->HomeAgentLifetime, VTY_NEWLINE);
-	else
-	  vty_out (vty, "  Home Agent lifetime tracks ra-lifetime%s",
-	           VTY_NEWLINE);
-	vty_out (vty, "  Home Agent preference is %u%s",
-	         rtadv->HomeAgentPreference, VTY_NEWLINE);
-      }
-      if (listcount (rtadv->AdvRDNSSList))
-		  vty_out (vty, "  ND router advertisements with "
-                "RDNSS information.%s", VTY_NEWLINE);
-      if (listcount (rtadv->AdvDNSSLList))
-        vty_out (vty, "  ND router advertisements with DNSSL information%s", VTY_NEWLINE);
-      if (rtadv->AdvIntervalOption)
-      	vty_out (vty, "  ND router advertisements with Adv. Interval option.%s",
-		 VTY_NEWLINE);
-    }
-}
-#endif /* HAVE_RTADV */
-
 /* Interface's information print out to vty interface. */
 static void
 if_dump_vty (struct vty *vty, struct interface *ifp)
@@ -953,11 +851,8 @@ if_dump_vty (struct vty *vty, struct interface *ifp)
         vty_out(vty, "    Neighbor ASBR IP: %s AS: %u %s", inet_ntoa(iflp->rmt_ip), iflp->rmt_as, VTY_NEWLINE);
     }
 
- #ifdef RTADV
-   nd_dump_vty (vty, ifp);
- #endif /* RTADV */
 #if defined (HAVE_RTADV)
-  nd_dump_vty (vty, ifp);
+  rtadv_if_dump_vty (vty, &((struct zebra_if *) ifp->info)->rtadv);
 #endif /* HAVE_RTADV */
 
 #ifdef HAVE_PROC_NET_DEV

+ 2 - 144
zebra/interface.h

@@ -25,6 +25,8 @@
 #include "redistribute.h"
 #include "event_counter.h"
 
+#include "zebra/rtadv.h"
+
 #ifdef HAVE_IRDP
 #include "zebra/irdp.h"
 #endif
@@ -51,150 +53,6 @@ struct zebra_if_defaults {
   zebra_if_linkdetect linkdetect;
 };
 
-#if defined (HAVE_RTADV)
-/* Router advertisement parameter.  From RFC4861, RFC6275 and RFC4191. */
-struct rtadvconf
-{
-  /* A flag indicating whether or not the router sends periodic Router
-     Advertisements and responds to Router Solicitations.
-     Default: FALSE */
-  int AdvSendAdvertisements;
-
-  /* The maximum time allowed between sending unsolicited multicast
-     Router Advertisements from the interface, in milliseconds.
-     MUST be no less than 70 ms [RFC6275 7.5] and no greater
-     than 1800000 ms [RFC4861 6.2.1].
-
-     Default: 600000 milliseconds */
-  int MaxRtrAdvInterval;
-#define RTADV_MAX_RTR_ADV_INTERVAL 600000
-
-  /* The minimum time allowed between sending unsolicited multicast
-     Router Advertisements from the interface, in milliseconds.
-     MUST be no less than 30 ms [RFC6275 7.5].
-     MUST be no greater than .75 * MaxRtrAdvInterval.
-
-     Default: 0.33 * MaxRtrAdvInterval */
-  int MinRtrAdvInterval; /* This field is currently unused. */
-#define RTADV_MIN_RTR_ADV_INTERVAL (0.33 * RTADV_MAX_RTR_ADV_INTERVAL)
-
-  /* Unsolicited Router Advertisements' interval timer. */
-  int AdvIntervalTimer;
-
-  /* The TRUE/FALSE value to be placed in the "Managed address
-     configuration" flag field in the Router Advertisement.  See
-     [ADDRCONF].
- 
-     Default: FALSE */
-  int AdvManagedFlag;
-
-
-  /* The TRUE/FALSE value to be placed in the "Other stateful
-     configuration" flag field in the Router Advertisement.  See
-     [ADDRCONF].
-
-     Default: FALSE */
-  int AdvOtherConfigFlag;
-
-  /* The value to be placed in MTU options sent by the router.  A
-     value of zero indicates that no MTU options are sent.
-
-     Default: 0 */
-  int AdvLinkMTU;
-
-
-  /* The value to be placed in the Reachable Time field in the Router
-     Advertisement messages sent by the router.  The value zero means
-     unspecified (by this router).  MUST be no greater than 3,600,000
-     milliseconds (1 hour).
-
-     Default: 0 */
-  u_int32_t AdvReachableTime;
-#define RTADV_MAX_REACHABLE_TIME 3600000
-
-
-  /* The value to be placed in the Retrans Timer field in the Router
-     Advertisement messages sent by the router.  The value zero means
-     unspecified (by this router).
-
-     Default: 0 */
-  int AdvRetransTimer;
-
-  /* The default value to be placed in the Cur Hop Limit field in the
-     Router Advertisement messages sent by the router.  The value
-     should be set to that current diameter of the Internet.  The
-     value zero means unspecified (by this router).
-
-     Default: The value specified in the "Assigned Numbers" RFC
-     [ASSIGNED] that was in effect at the time of implementation. */
-  int AdvCurHopLimit;
-
-  /* The value to be placed in the Router Lifetime field of Router
-     Advertisements sent from the interface, in seconds.  MUST be
-     either zero or between MaxRtrAdvInterval and 9000 seconds.  A
-     value of zero indicates that the router is not to be used as a
-     default router.
-
-     Default: 3 * MaxRtrAdvInterval */
-  int AdvDefaultLifetime;
-#define RTADV_MAX_RTRLIFETIME 9000 /* 2.5 hours */
-
-  /* A list of prefixes to be placed in Prefix Information options in
-     Router Advertisement messages sent from the interface.
-
-     Default: all prefixes that the router advertises via routing
-     protocols as being on-link for the interface from which the
-     advertisement is sent. The link-local prefix SHOULD NOT be
-     included in the list of advertised prefixes. */
-  struct list *AdvPrefixList;
-
-  /* The TRUE/FALSE value to be placed in the "Home agent"
-     flag field in the Router Advertisement.  See [RFC6275 7.1].
-
-     Default: FALSE */
-  int AdvHomeAgentFlag;
-#ifndef ND_RA_FLAG_HOME_AGENT
-#define ND_RA_FLAG_HOME_AGENT 	0x20
-#endif
-
-  /* The value to be placed in Home Agent Information option if Home 
-     Flag is set.
-     Default: 0 */
-  int HomeAgentPreference;
-
-  /* The value to be placed in Home Agent Information option if Home 
-     Flag is set. Lifetime (seconds) MUST not be greater than 18.2 
-     hours. 
-     The value 0 has special meaning: use of AdvDefaultLifetime value.
-     
-     Default: 0 */
-  int HomeAgentLifetime;
-#define RTADV_MAX_HALIFETIME 65520 /* 18.2 hours */
-
-  /* The TRUE/FALSE value to insert or not an Advertisement Interval
-     option. See [RFC 6275 7.3]
-
-     Default: FALSE */
-  int AdvIntervalOption;
-
-  /* The value to be placed in the Default Router Preference field of
-     a router advertisement. See [RFC 4191 2.1 & 2.2]
-
-     Default: 0 (medium) */
-  int DefaultPreference;
-#define RTADV_PREF_MEDIUM 0x0 /* Per RFC4191. */
-
-  /* A list of Recursive DNS server addresses specified in
-     RFC 6106 */
-  struct list *AdvRDNSSList;
-#define	RTADV_DNS_INFINITY_LIFETIME (0xffffffff)
-#define	RTADV_DNS_OBSOLETE_LIFETIME (0x00000000)
-  /* a list of configured DNS Search List domains (RFC6106) */
-  struct list *AdvDNSSLList;
-};
-
-#endif /* HAVE_RTADV */
-
 /* `zebra' daemon local interface structure. */
 struct zebra_if
 {

+ 85 - 5
zebra/rtadv.c

@@ -28,7 +28,6 @@
 #include "if.h"
 #include "log.h"
 #include "prefix.h"
-#include "linklist.h"
 #include "command.h"
 #include "privs.h"
 #include "vrf.h"
@@ -67,6 +66,17 @@ static void rtadv_event (struct zebra_vrf *, enum rtadv_event, int);
 
 static int if_join_all_router (int, struct interface *);
 static int if_leave_all_router (int, struct interface *);
+
+/* Order is intentional.  Matches RFC4191.  This array is also used for
+   command matching, so only modify with care. */
+static const struct message rtadv_pref_strs[] =
+{
+  { RTADV_PREF_MEDIUM,   "medium"  },
+  { RTADV_PREF_HIGH,     "high"    },
+  { RTADV_PREF_RESERVED, "INVALID" },
+  { RTADV_PREF_LOW,      "low"     },
+};
+static const size_t rtadv_pref_strs_max = sizeof (rtadv_pref_strs) / sizeof (struct message);
 
 static int
 rtadv_recv_packet (int sock, u_char *buf, int buflen,
@@ -1578,14 +1588,14 @@ DEFUN (ipv6_nd_router_preference,
 {
   struct interface *ifp;
   struct zebra_if *zif;
-  int i = 0;
+  unsigned int i = 0;
 
   ifp = (struct interface *) vty->index;
   zif = ifp->info;
 
-  while (0 != rtadv_pref_strs[i])
+  while (i < rtadv_pref_strs_max)
     {
-      if (strncmp (argv[0], rtadv_pref_strs[i], 1) == 0)
+      if (argv[0][0] == rtadv_pref_strs[i].str[0])
 	{
 	  zif->rtadv.DefaultPreference = i;
 	  zif->rtadv.AdvIntervalTimer = 0; /* resend immediately */
@@ -2043,7 +2053,7 @@ rtadv_config_write (struct vty *vty, struct interface *ifp)
 
   if (zif->rtadv.DefaultPreference != RTADV_PREF_MEDIUM)
     vty_out (vty, " ipv6 nd router-preference %s%s",
-	     rtadv_pref_strs[zif->rtadv.DefaultPreference],
+	     rtadv_pref_strs[zif->rtadv.DefaultPreference].str,
 	     VTY_NEWLINE);
 
   if (zif->rtadv.AdvLinkMTU)
@@ -2289,6 +2299,76 @@ if_leave_all_router (int sock, struct interface *ifp)
   return 0;
 }
 
+/* Dump interface ND information to vty. */
+void
+rtadv_if_dump_vty (struct vty *vty, const struct rtadvconf *conf)
+{
+  if (! conf->AdvSendAdvertisements)
+    return;
+  vty_out (vty, "  ND advertised reachable time is %d milliseconds%s",
+           conf->AdvReachableTime, VTY_NEWLINE);
+  vty_out (vty, "  ND advertised retransmit interval is %d milliseconds%s",
+           conf->AdvRetransTimer, VTY_NEWLINE);
+  if (conf->MaxRtrAdvInterval % 1000)
+    vty_out (vty, "  ND router advertisements are sent every %d milliseconds%s",
+             conf->MaxRtrAdvInterval, VTY_NEWLINE);
+  else
+    vty_out (vty, "  ND router advertisements are sent every %d seconds%s",
+             conf->MaxRtrAdvInterval / 1000, VTY_NEWLINE);
+  if (conf->AdvDefaultLifetime != -1)
+    vty_out (vty, "  ND router advertisements live for %d seconds%s",
+             conf->AdvDefaultLifetime, VTY_NEWLINE);
+  else
+    vty_out (vty, "  ND router advertisements lifetime tracks ra-interval%s", VTY_NEWLINE);
+  vty_out (vty, "  ND router advertisement default router preference is %s%s",
+           LOOKUP (rtadv_pref_strs, conf->DefaultPreference), VTY_NEWLINE);
+  if (conf->AdvManagedFlag)
+    vty_out (vty, "  Hosts use DHCP to obtain routable addresses.%s", VTY_NEWLINE);
+  else
+    vty_out (vty, "  Hosts use stateless autoconfig for addresses.%s", VTY_NEWLINE);
+  if (conf->AdvHomeAgentFlag)
+  {
+    vty_out (vty, "  ND router advertisements with Home Agent flag bit set.%s", VTY_NEWLINE);
+    if (conf->HomeAgentLifetime != -1)
+      vty_out (vty, "  Home Agent lifetime is %u seconds%s", conf->HomeAgentLifetime, VTY_NEWLINE);
+    else
+      vty_out (vty, "  Home Agent lifetime tracks ra-lifetime%s", VTY_NEWLINE);
+    vty_out (vty, "  Home Agent preference is %u%s", conf->HomeAgentPreference, VTY_NEWLINE);
+  }
+  if (listcount (conf->AdvRDNSSList))
+    vty_out (vty, "  ND router advertisements with RDNSS information.%s", VTY_NEWLINE);
+  if (listcount (conf->AdvDNSSLList))
+    vty_out (vty, "  ND router advertisements with DNSSL information%s", VTY_NEWLINE);
+  if (conf->AdvIntervalOption)
+    vty_out (vty, "  ND router advertisements with Adv. Interval option.%s", VTY_NEWLINE);
+}
+
+/* Set default router advertise values. */
+void
+rtadv_if_new_hook (struct rtadvconf *conf)
+{
+  conf->AdvSendAdvertisements = 0;
+  conf->MaxRtrAdvInterval = RTADV_MAX_RTR_ADV_INTERVAL;
+  conf->MinRtrAdvInterval = RTADV_MIN_RTR_ADV_INTERVAL;
+  conf->AdvIntervalTimer = 0;
+  conf->AdvManagedFlag = 0;
+  conf->AdvOtherConfigFlag = 0;
+  conf->AdvHomeAgentFlag = 0;
+  conf->AdvLinkMTU = 0;
+  conf->AdvReachableTime = 0;
+  conf->AdvRetransTimer = 0;
+  conf->AdvCurHopLimit = 0;
+  conf->AdvDefaultLifetime = -1; /* derive from MaxRtrAdvInterval */
+  conf->HomeAgentPreference = 0;
+  conf->HomeAgentLifetime = -1; /* derive from AdvDefaultLifetime */
+  conf->AdvIntervalOption = 0;
+  conf->DefaultPreference = RTADV_PREF_MEDIUM;
+
+  conf->AdvPrefixList = list_new ();
+  conf->AdvRDNSSList = list_new ();
+  conf->AdvDNSSLList = list_new ();
+}
+
 #else
 void
 rtadv_init (struct zebra_vrf *zvrf)

+ 156 - 5
zebra/rtadv.h

@@ -24,7 +24,154 @@
 #define _ZEBRA_RTADV_H
 
 #include "vty.h"
-#include "zebra/interface.h"
+#include "linklist.h"
+#include "if.h"
+
+/* Router advertisement parameter.  From RFC4861, RFC6275 and RFC4191. */
+struct rtadvconf
+{
+  /* A flag indicating whether or not the router sends periodic Router
+     Advertisements and responds to Router Solicitations.
+     Default: FALSE */
+  int AdvSendAdvertisements;
+
+  /* The maximum time allowed between sending unsolicited multicast
+     Router Advertisements from the interface, in milliseconds.
+     MUST be no less than 70 ms [RFC6275 7.5] and no greater
+     than 1800000 ms [RFC4861 6.2.1].
+
+     Default: 600000 milliseconds */
+  int MaxRtrAdvInterval;
+#define RTADV_MAX_RTR_ADV_INTERVAL 600000
+
+  /* The minimum time allowed between sending unsolicited multicast
+     Router Advertisements from the interface, in milliseconds.
+     MUST be no less than 30 ms [RFC6275 7.5].
+     MUST be no greater than .75 * MaxRtrAdvInterval.
+
+     Default: 0.33 * MaxRtrAdvInterval */
+  int MinRtrAdvInterval; /* This field is currently unused. */
+#define RTADV_MIN_RTR_ADV_INTERVAL (0.33 * RTADV_MAX_RTR_ADV_INTERVAL)
+
+  /* Unsolicited Router Advertisements' interval timer. */
+  int AdvIntervalTimer;
+
+  /* The TRUE/FALSE value to be placed in the "Managed address
+     configuration" flag field in the Router Advertisement.  See
+     [ADDRCONF].
+
+     Default: FALSE */
+  int AdvManagedFlag;
+
+
+  /* The TRUE/FALSE value to be placed in the "Other stateful
+     configuration" flag field in the Router Advertisement.  See
+     [ADDRCONF].
+
+     Default: FALSE */
+  int AdvOtherConfigFlag;
+
+  /* The value to be placed in MTU options sent by the router.  A
+     value of zero indicates that no MTU options are sent.
+
+     Default: 0 */
+  int AdvLinkMTU;
+
+
+  /* The value to be placed in the Reachable Time field in the Router
+     Advertisement messages sent by the router.  The value zero means
+     unspecified (by this router).  MUST be no greater than 3,600,000
+     milliseconds (1 hour).
+
+     Default: 0 */
+  u_int32_t AdvReachableTime;
+#define RTADV_MAX_REACHABLE_TIME 3600000
+
+
+  /* The value to be placed in the Retrans Timer field in the Router
+     Advertisement messages sent by the router.  The value zero means
+     unspecified (by this router).
+
+     Default: 0 */
+  int AdvRetransTimer;
+
+  /* The default value to be placed in the Cur Hop Limit field in the
+     Router Advertisement messages sent by the router.  The value
+     should be set to that current diameter of the Internet.  The
+     value zero means unspecified (by this router).
+
+     Default: The value specified in the "Assigned Numbers" RFC
+     [ASSIGNED] that was in effect at the time of implementation. */
+  int AdvCurHopLimit;
+
+  /* The value to be placed in the Router Lifetime field of Router
+     Advertisements sent from the interface, in seconds.  MUST be
+     either zero or between MaxRtrAdvInterval and 9000 seconds.  A
+     value of zero indicates that the router is not to be used as a
+     default router.
+
+     Default: 3 * MaxRtrAdvInterval */
+  int AdvDefaultLifetime;
+#define RTADV_MAX_RTRLIFETIME 9000 /* 2.5 hours */
+
+  /* A list of prefixes to be placed in Prefix Information options in
+     Router Advertisement messages sent from the interface.
+
+     Default: all prefixes that the router advertises via routing
+     protocols as being on-link for the interface from which the
+     advertisement is sent. The link-local prefix SHOULD NOT be
+     included in the list of advertised prefixes. */
+  struct list *AdvPrefixList;
+
+  /* The TRUE/FALSE value to be placed in the "Home agent"
+     flag field in the Router Advertisement.  See [RFC6275 7.1].
+
+     Default: FALSE */
+  int AdvHomeAgentFlag;
+#ifndef ND_RA_FLAG_HOME_AGENT
+#define ND_RA_FLAG_HOME_AGENT 	0x20
+#endif
+
+  /* The value to be placed in Home Agent Information option if Home
+     Flag is set.
+     Default: 0 */
+  int HomeAgentPreference;
+
+  /* The value to be placed in Home Agent Information option if Home
+     Flag is set. Lifetime (seconds) MUST not be greater than 18.2
+     hours.
+     The value 0 has special meaning: use of AdvDefaultLifetime value.
+
+     Default: 0 */
+  int HomeAgentLifetime;
+#define RTADV_MAX_HALIFETIME 65520 /* 18.2 hours */
+
+  /* The TRUE/FALSE value to insert or not an Advertisement Interval
+     option. See [RFC 6275 7.3]
+
+     Default: FALSE */
+  int AdvIntervalOption;
+
+  /* The value to be placed in the Default Router Preference field of
+     a router advertisement. See [RFC 4191 2.1 & 2.2]
+
+     Default: 0 (medium) */
+  int DefaultPreference;
+  /* RFC4191 2.1. Preference Values: "Preference values are encoded as
+     a two-bit signed integer, as follows:" */
+#define RTADV_PREF_HIGH     0x1 /* 01      High                        */
+#define RTADV_PREF_MEDIUM   0x0 /* 00      Medium (default)            */
+#define RTADV_PREF_RESERVED 0x2 /* 10      Reserved - MUST NOT be sent */
+#define RTADV_PREF_LOW      0x3 /* 11      Low                         */
+
+  /* A list of Recursive DNS server addresses specified in
+     RFC 6106 */
+  struct list *AdvRDNSSList;
+#define	RTADV_DNS_INFINITY_LIFETIME (0xffffffff)
+#define	RTADV_DNS_OBSOLETE_LIFETIME (0x00000000)
+  /* a list of configured DNS Search List domains (RFC6106) */
+  struct list *AdvDNSSLList;
+};
 
 /* NB: RTADV is defined in zebra/interface.h above */
 #if defined (HAVE_RTADV)
@@ -58,8 +205,6 @@ struct rtadv_prefix
 
 };
 
-extern void rtadv_config_write (struct vty *, struct interface *);
-
 /* RFC4584 Extension to Sockets API for Mobile IPv6 */
 
 #ifndef ND_OPT_ADV_INTERVAL
@@ -149,12 +294,18 @@ struct rtadv_dnssl_entry
   u_int32_t lifetime;
 };
 
-extern const char *rtadv_pref_strs[];
-
 #endif /* HAVE_RTADV */
 
+extern void rtadv_config_write (struct vty *, struct interface *);
+
 extern void rtadv_init (struct zebra_vrf *);
 extern void rtadv_terminate (struct zebra_vrf *);
 extern void rtadv_cmd_init (void);
 
+/* Router advertisement feature. */
+#ifdef HAVE_RTADV
+extern void rtadv_if_dump_vty (struct vty *, const struct rtadvconf *);
+extern void rtadv_if_new_hook (struct rtadvconf *);
+#endif
+
 #endif /* _ZEBRA_RTADV_H */

+ 16 - 0
zebra/test_main.c

@@ -73,6 +73,21 @@ zebra_capabilities_t _caps_p [] =
   ZCAP_NET_RAW,
 };
 
+/* zebra privileges to run with */
+struct zebra_privs_t zserv_privs =
+{
+#if defined(QUAGGA_USER) && defined(QUAGGA_GROUP)
+  .user = QUAGGA_USER,
+  .group = QUAGGA_GROUP,
+#endif
+#ifdef VTY_GROUP
+  .vty_group = VTY_GROUP,
+#endif
+  .caps_p = _caps_p,
+  .cap_num_p = sizeof(_caps_p)/sizeof(_caps_p[0]),
+  .cap_num_i = 0
+};
+
 /* Default configuration file path. */
 char config_default[] = SYSCONFDIR DEFAULT_CONFIG_FILE;
 
@@ -344,6 +359,7 @@ main (int argc, char **argv)
   /* Make master thread emulator. */
   zebrad.master = thread_master_create ();
 
+  zprivs_init (&zserv_privs);
   /* Vty related initialize. */
   signal_init (zebrad.master, array_size(zebra_signals), zebra_signals);
   cmd_init (1);