[radvd-devel-l] [PATCH 2/2] RADVD: Setup Inteface Variables
Pekka Savola
pekkas at netcore.fi
Fri Dec 30 10:15:51 EST 2005
Hi,
Thanks for these patches. I've committed them into CVS.
I made some minor changes to the second patch (snprinf vs sprintf
etc.). It also triggered me to do a signed/unsigned cleanup and some
other warning fixes, so you may want to resync from CVS.
On Fri, 23 Dec 2005, YOSHIFUJI Hideaki / µÈÆ£±ÑÌÀ wrote:
> Set up our own interface variables (LinkMTU, CurrentHopLimit,
> BaseReachableTime and RetransTimer) as well.
>
> This is required to pass the IPv6 Ready Logo Phase-2
> IPv6 Core Protocols Self Test.
>
> Related Test: Phase-2 Router ND #109
>
> Index: device-bsd44.c
> ===================================================================
> RCS file: /work/cvsroot/radvd/device-bsd44.c,v
> retrieving revision 1.18
> diff -u -r1.18 device-bsd44.c
> --- device-bsd44.c 1 Dec 2005 06:32:23 -0000 1.18
> +++ device-bsd44.c 22 Dec 2005 13:37:59 -0000
> @@ -255,3 +255,34 @@
>
> return 0;
> }
> +
> +int
> +set_interface_linkmtu(const char *iface, uint32_t mtu)
> +{
> + dlog(LOG_DEBUG, 4, "cannot set LinkMTU (%u) for %s",
> + (unsigned int)mtu, iface");
> + return -1;
> +}
> +
> +int
> +set_interface_curhlim(const char *iface, uint8_t hlim)
> +{
> + dlog(LOG_DEBUG, 4, "cannot set CurHopLimit (%u) for %s",
> + (unsigned int)hlim, iface");
> + return -1;
> +}
> +
> +set_interface_reachtime(const char *iface, uint32_t rtime)
> +{
> + dlog(LOG_DEBUG, 4, "cannot set BaseReachableTime (%u) for %s",
> + (unsigned int)rtime, iface");
> + return -1;
> +}
> +
> +set_interface_retranstimer(const char *iface, uint32_t rettimer)
> +{
> + dlog(LOG_DEBUG, 4, "cannot set RetransTimer (%u) for %s",
> + (unsigned int)rettimer, iface");
> + return -1;
> +}
> +
> Index: device-linux.c
> ===================================================================
> RCS file: /work/cvsroot/radvd/device-linux.c,v
> retrieving revision 1.16
> diff -u -r1.16 device-linux.c
> --- device-linux.c 28 Oct 2005 14:29:49 -0000 1.16
> +++ device-linux.c 22 Dec 2005 13:38:00 -0000
> @@ -258,3 +258,74 @@
>
> return 0;
> }
> +
> +static int
> +set_interface_var(const char *iface,
> + const char *var, const char *name,
> + uint32_t val)
> +{
> + FILE *fp;
> + char spath[64+IF_NAMESIZE];
> + sprintf(spath, var, iface);
> +
> + fp = fopen(spath, "w");
> + if (!fp) {
> + if (name)
> + flog(LOG_ERR, "failed to set %s (%u) for %s",
> + name, (unsigned int)val, iface);
> + return -1;
> + }
> + fprintf(fp, "%u", (unsigned int)val);
> + fclose(fp);
> +
> + return 0;
> +}
> +
> +int
> +set_interface_linkmtu(const char *iface, uint32_t mtu)
> +{
> + return set_interface_var(iface,
> + PROC_SYS_IP6_LINKMTU, "LinkMTU",
> + mtu);
> +}
> +
> +int
> +set_interface_curhlim(const char *iface, uint8_t hlim)
> +{
> + return set_interface_var(iface,
> + PROC_SYS_IP6_CURHLIM, "CurHopLimit",
> + hlim);
> +}
> +
> +int
> +set_interface_reachtime(const char *iface, uint32_t rtime)
> +{
> + int ret;
> + ret = set_interface_var(iface,
> + PROC_SYS_IP6_BASEREACHTIME_MS,
> + NULL,
> + rtime);
> + if (ret)
> + ret = set_interface_var(iface,
> + PROC_SYS_IP6_BASEREACHTIME,
> + "BaseReachableTimer",
> + rtime / 1000);
> + return ret;
> +}
> +
> +int
> +set_interface_retranstimer(const char *iface, uint32_t rettimer)
> +{
> + int ret;
> + ret = set_interface_var(iface,
> + PROC_SYS_IP6_RETRANSTIMER_MS,
> + NULL,
> + rettimer);
> + if (ret)
> + ret = set_interface_var(iface,
> + PROC_SYS_IP6_RETRANSTIMER,
> + "RetransTimer",
> + rettimer / 1000);
> + return ret;
> +}
> +
> Index: pathnames.h
> ===================================================================
> RCS file: /work/cvsroot/radvd/pathnames.h,v
> retrieving revision 1.6
> diff -u -r1.6 pathnames.h
> --- pathnames.h 18 Oct 2005 19:17:29 -0000 1.6
> +++ pathnames.h 22 Dec 2005 13:38:00 -0000
> @@ -35,6 +35,12 @@
> #ifdef __linux__
> #define SYSCTL_IP6_FORWARDING CTL_NET, NET_IPV6, NET_IPV6_CONF, NET_PROTO_CONF_ALL, NET_IPV6_FORWARDING
> #define PROC_SYS_IP6_FORWARDING "/proc/sys/net/ipv6/conf/all/forwarding"
> +#define PROC_SYS_IP6_LINKMTU "/proc/sys/net/ipv6/conf/%s/mtu"
> +#define PROC_SYS_IP6_CURHLIM "/proc/sys/net/ipv6/conf/%s/hop_limit"
> +#define PROC_SYS_IP6_BASEREACHTIME_MS "/proc/sys/net/ipv6/neigh/%s/base_reachable_time_ms"
> +#define PROC_SYS_IP6_BASEREACHTIME "/proc/sys/net/ipv6/neigh/%s/base_reachable_time"
> +#define PROC_SYS_IP6_RETRANSTIMER_MS "/proc/sys/net/ipv6/neigh/%s/retrans_time_ms"
> +#define PROC_SYS_IP6_RETRANSTIMER "/proc/sys/net/ipv6/neigh/%s/retrans_time"
> #else /* BSD */
> #define SYSCTL_IP6_FORWARDING CTL_NET, PF_INET6, IPPROTO_IPV6, IPV6CTL_FORWARDING
> #endif
> Index: radvd.c
> ===================================================================
> RCS file: /work/cvsroot/radvd/radvd.c,v
> retrieving revision 1.23
> diff -u -r1.23 radvd.c
> --- radvd.c 18 Oct 2005 19:17:29 -0000 1.23
> +++ radvd.c 22 Dec 2005 13:38:00 -0000
> @@ -55,6 +55,7 @@
> void sigterm_handler(int sig);
> void sigint_handler(int sig);
> void timer_handler(void *data);
> +void config_interface(void);
> void kickoff_adverts(void);
> void stop_adverts(void);
> void reload_config(void);
> @@ -258,6 +259,7 @@
>
> close(fd);
>
> + config_interface();
> kickoff_adverts();
>
> /* enter loop */
> @@ -304,6 +306,23 @@
> }
>
> void
> +config_interface(void)
> +{
> + struct Interface *iface;
> + for(iface=IfaceList; iface; iface=iface->next)
> + {
> + if (iface->AdvLinkMTU)
> + set_interface_linkmtu(iface->Name, iface->AdvLinkMTU);
> + if (iface->AdvCurHopLimit)
> + set_interface_curhlim(iface->Name, iface->AdvCurHopLimit);
> + if (iface->AdvReachableTime)
> + set_interface_reachtime(iface->Name, iface->AdvReachableTime);
> + if (iface->AdvRetransTimer)
> + set_interface_retranstimer(iface->Name, iface->AdvRetransTimer);
> + }
> +}
> +
> +void
> kickoff_adverts(void)
> {
> struct Interface *iface;
> @@ -406,6 +425,7 @@
> if (readin_config(conf_file) < 0)
> exit(1);
>
> + config_interface();
> kickoff_adverts();
>
> flog(LOG_INFO, "resuming normal operation");
>
>
--
Pekka Savola "You each name yourselves king, yet the
Netcore Oy kingdom bleeds."
Systems. Networks. Security. -- George R.R. Martin: A Clash of Kings
More information about the radvd-devel-l
mailing list