diff options
| author | whitespace / reindent <invalid@invalid.invalid> | 2017-07-17 14:03:14 +0200 | 
|---|---|---|
| committer | whitespace / reindent <invalid@invalid.invalid> | 2017-07-17 14:04:07 +0200 | 
| commit | d62a17aedeb0eebdba98238874bb13d62c48dbf9 (patch) | |
| tree | 3b319b1d61c8b85b4d1f06adf8b844bb8a9b5107 /ripngd | |
| parent | 888ac268a0077fc9ebd1218cec6ae472af0bfc40 (diff) | |
*: reindentreindent-master-after
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'`
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'ripngd')
| -rw-r--r-- | ripngd/ripng_debug.c | 240 | ||||
| -rw-r--r-- | ripngd/ripng_debug.h | 4 | ||||
| -rw-r--r-- | ripngd/ripng_interface.c | 1592 | ||||
| -rw-r--r-- | ripngd/ripng_main.c | 180 | ||||
| -rw-r--r-- | ripngd/ripng_memory.c | 10 | ||||
| -rw-r--r-- | ripngd/ripng_nexthop.c | 282 | ||||
| -rw-r--r-- | ripngd/ripng_nexthop.h | 35 | ||||
| -rw-r--r-- | ripngd/ripng_offset.c | 562 | ||||
| -rw-r--r-- | ripngd/ripng_peer.c | 231 | ||||
| -rw-r--r-- | ripngd/ripng_route.c | 215 | ||||
| -rw-r--r-- | ripngd/ripng_route.h | 47 | ||||
| -rw-r--r-- | ripngd/ripng_routemap.c | 498 | ||||
| -rw-r--r-- | ripngd/ripng_zebra.c | 758 | ||||
| -rw-r--r-- | ripngd/ripngd.c | 4676 | ||||
| -rw-r--r-- | ripngd/ripngd.h | 457 | 
15 files changed, 4768 insertions, 5019 deletions
diff --git a/ripngd/ripng_debug.c b/ripngd/ripng_debug.c index 3bc9b4b210..5d7a2cf9ff 100644 --- a/ripngd/ripng_debug.c +++ b/ripngd/ripng_debug.c @@ -35,30 +35,28 @@ DEFUN (show_debugging_ripng,         DEBUG_STR         "RIPng configuration\n")  { -  vty_out (vty, "RIPng debugging status:\n"); - -  if (IS_RIPNG_DEBUG_EVENT) -    vty_out (vty, "  RIPng event debugging is on\n"); - -  if (IS_RIPNG_DEBUG_PACKET) -    { -      if (IS_RIPNG_DEBUG_SEND && IS_RIPNG_DEBUG_RECV) -	{ -	  vty_out (vty,"  RIPng packet debugging is on\n"); -	} -      else -	{ -	  if (IS_RIPNG_DEBUG_SEND) -	    vty_out (vty,"  RIPng packet send debugging is on\n"); -	  else -	    vty_out (vty,"  RIPng packet receive debugging is on\n"); +	vty_out(vty, "RIPng debugging status:\n"); + +	if (IS_RIPNG_DEBUG_EVENT) +		vty_out(vty, "  RIPng event debugging is on\n"); + +	if (IS_RIPNG_DEBUG_PACKET) { +		if (IS_RIPNG_DEBUG_SEND && IS_RIPNG_DEBUG_RECV) { +			vty_out(vty, "  RIPng packet debugging is on\n"); +		} else { +			if (IS_RIPNG_DEBUG_SEND) +				vty_out(vty, +					"  RIPng packet send debugging is on\n"); +			else +				vty_out(vty, +					"  RIPng packet receive debugging is on\n"); +		}  	} -    } -  if (IS_RIPNG_DEBUG_ZEBRA) -    vty_out (vty, "  RIPng zebra debugging is on\n"); +	if (IS_RIPNG_DEBUG_ZEBRA) +		vty_out(vty, "  RIPng zebra debugging is on\n"); -  return CMD_SUCCESS; +	return CMD_SUCCESS;  }  DEFUN (debug_ripng_events, @@ -68,8 +66,8 @@ DEFUN (debug_ripng_events,         "RIPng configuration\n"         "Debug option set for ripng events\n")  { -  ripng_debug_event = RIPNG_DEBUG_EVENT; -  return CMD_WARNING_CONFIG_FAILED; +	ripng_debug_event = RIPNG_DEBUG_EVENT; +	return CMD_WARNING_CONFIG_FAILED;  }  DEFUN (debug_ripng_packet, @@ -79,10 +77,10 @@ DEFUN (debug_ripng_packet,         "RIPng configuration\n"         "Debug option set for ripng packet\n")  { -  ripng_debug_packet = RIPNG_DEBUG_PACKET; -  ripng_debug_packet |= RIPNG_DEBUG_SEND; -  ripng_debug_packet |= RIPNG_DEBUG_RECV; -  return CMD_SUCCESS; +	ripng_debug_packet = RIPNG_DEBUG_PACKET; +	ripng_debug_packet |= RIPNG_DEBUG_SEND; +	ripng_debug_packet |= RIPNG_DEBUG_RECV; +	return CMD_SUCCESS;  }  DEFUN (debug_ripng_packet_direct, @@ -94,14 +92,18 @@ DEFUN (debug_ripng_packet_direct,         "Debug option set for receive packet\n"         "Debug option set for send packet\n")  { -  int idx_recv_send = 3; -  ripng_debug_packet |= RIPNG_DEBUG_PACKET; -  if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) -    ripng_debug_packet |= RIPNG_DEBUG_SEND; -  if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) -    ripng_debug_packet |= RIPNG_DEBUG_RECV; - -  return CMD_SUCCESS; +	int idx_recv_send = 3; +	ripng_debug_packet |= RIPNG_DEBUG_PACKET; +	if (strncmp("send", argv[idx_recv_send]->arg, +		    strlen(argv[idx_recv_send]->arg)) +	    == 0) +		ripng_debug_packet |= RIPNG_DEBUG_SEND; +	if (strncmp("recv", argv[idx_recv_send]->arg, +		    strlen(argv[idx_recv_send]->arg)) +	    == 0) +		ripng_debug_packet |= RIPNG_DEBUG_RECV; + +	return CMD_SUCCESS;  }  DEFUN (debug_ripng_zebra, @@ -111,8 +113,8 @@ DEFUN (debug_ripng_zebra,         "RIPng configuration\n"         "Debug option set for ripng and zebra communication\n")  { -  ripng_debug_zebra = RIPNG_DEBUG_ZEBRA; -  return CMD_WARNING_CONFIG_FAILED; +	ripng_debug_zebra = RIPNG_DEBUG_ZEBRA; +	return CMD_WARNING_CONFIG_FAILED;  }  DEFUN (no_debug_ripng_events, @@ -123,8 +125,8 @@ DEFUN (no_debug_ripng_events,         "RIPng configuration\n"         "Debug option set for ripng events\n")  { -  ripng_debug_event = 0; -  return CMD_SUCCESS; +	ripng_debug_event = 0; +	return CMD_SUCCESS;  }  DEFUN (no_debug_ripng_packet, @@ -135,8 +137,8 @@ DEFUN (no_debug_ripng_packet,         "RIPng configuration\n"         "Debug option set for ripng packet\n")  { -  ripng_debug_packet = 0; -  return CMD_SUCCESS; +	ripng_debug_packet = 0; +	return CMD_SUCCESS;  }  DEFUN (no_debug_ripng_packet_direct, @@ -149,22 +151,23 @@ DEFUN (no_debug_ripng_packet_direct,         "Debug option set for receive packet\n"         "Debug option set for send packet\n")  { -  int idx_recv_send = 4; -  if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) -    { -      if (IS_RIPNG_DEBUG_RECV) -       ripng_debug_packet &= ~RIPNG_DEBUG_SEND; -      else -       ripng_debug_packet = 0; -    } -  else if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) -    { -      if (IS_RIPNG_DEBUG_SEND) -       ripng_debug_packet &= ~RIPNG_DEBUG_RECV; -      else -       ripng_debug_packet = 0; -    } -  return CMD_SUCCESS; +	int idx_recv_send = 4; +	if (strncmp("send", argv[idx_recv_send]->arg, +		    strlen(argv[idx_recv_send]->arg)) +	    == 0) { +		if (IS_RIPNG_DEBUG_RECV) +			ripng_debug_packet &= ~RIPNG_DEBUG_SEND; +		else +			ripng_debug_packet = 0; +	} else if (strncmp("recv", argv[idx_recv_send]->arg, +			   strlen(argv[idx_recv_send]->arg)) +		   == 0) { +		if (IS_RIPNG_DEBUG_SEND) +			ripng_debug_packet &= ~RIPNG_DEBUG_RECV; +		else +			ripng_debug_packet = 0; +	} +	return CMD_SUCCESS;  }  DEFUN (no_debug_ripng_zebra, @@ -175,86 +178,75 @@ DEFUN (no_debug_ripng_zebra,         "RIPng configuration\n"         "Debug option set for ripng and zebra communication\n")  { -  ripng_debug_zebra = 0; -  return CMD_WARNING_CONFIG_FAILED; +	ripng_debug_zebra = 0; +	return CMD_WARNING_CONFIG_FAILED;  }  /* Debug node. */ -static struct cmd_node debug_node = -{ -  DEBUG_NODE, -  "",				/* Debug node has no interface. */ -  1 /* VTYSH */ +static struct cmd_node debug_node = { +	DEBUG_NODE, "", /* Debug node has no interface. */ +	1		/* VTYSH */  }; -static int -config_write_debug (struct vty *vty) +static int config_write_debug(struct vty *vty)  { -  int write = 0; +	int write = 0; -  if (IS_RIPNG_DEBUG_EVENT) -    { -      vty_out (vty, "debug ripng events\n"); -      write++; -    } -  if (IS_RIPNG_DEBUG_PACKET) -    { -      if (IS_RIPNG_DEBUG_SEND && IS_RIPNG_DEBUG_RECV) -	{ -	  vty_out (vty,"debug ripng packet\n"); -	  write++; +	if (IS_RIPNG_DEBUG_EVENT) { +		vty_out(vty, "debug ripng events\n"); +		write++;  	} -      else -	{ -	  if (IS_RIPNG_DEBUG_SEND) -	    vty_out (vty,"debug ripng packet send\n"); -	  else -	    vty_out (vty,"debug ripng packet recv\n"); -	  write++; +	if (IS_RIPNG_DEBUG_PACKET) { +		if (IS_RIPNG_DEBUG_SEND && IS_RIPNG_DEBUG_RECV) { +			vty_out(vty, "debug ripng packet\n"); +			write++; +		} else { +			if (IS_RIPNG_DEBUG_SEND) +				vty_out(vty, "debug ripng packet send\n"); +			else +				vty_out(vty, "debug ripng packet recv\n"); +			write++; +		}  	} -    } -  if (IS_RIPNG_DEBUG_ZEBRA) -    { -      vty_out (vty, "debug ripng zebra\n"); -      write++; -    } -  return write; +	if (IS_RIPNG_DEBUG_ZEBRA) { +		vty_out(vty, "debug ripng zebra\n"); +		write++; +	} +	return write;  } -void -ripng_debug_reset () +void ripng_debug_reset()  { -  ripng_debug_event = 0; -  ripng_debug_packet = 0; -  ripng_debug_zebra = 0; +	ripng_debug_event = 0; +	ripng_debug_packet = 0; +	ripng_debug_zebra = 0;  } -void -ripng_debug_init () +void ripng_debug_init()  { -  ripng_debug_event = 0; -  ripng_debug_packet = 0; -  ripng_debug_zebra = 0; - -  install_node (&debug_node, config_write_debug); - -  install_element (VIEW_NODE, &show_debugging_ripng_cmd); - -  install_element (ENABLE_NODE, &debug_ripng_events_cmd); -  install_element (ENABLE_NODE, &debug_ripng_packet_cmd); -  install_element (ENABLE_NODE, &debug_ripng_packet_direct_cmd); -  install_element (ENABLE_NODE, &debug_ripng_zebra_cmd); -  install_element (ENABLE_NODE, &no_debug_ripng_events_cmd); -  install_element (ENABLE_NODE, &no_debug_ripng_packet_cmd); -  install_element (ENABLE_NODE, &no_debug_ripng_packet_direct_cmd); -  install_element (ENABLE_NODE, &no_debug_ripng_zebra_cmd); - -  install_element (CONFIG_NODE, &debug_ripng_events_cmd); -  install_element (CONFIG_NODE, &debug_ripng_packet_cmd); -  install_element (CONFIG_NODE, &debug_ripng_packet_direct_cmd); -  install_element (CONFIG_NODE, &debug_ripng_zebra_cmd); -  install_element (CONFIG_NODE, &no_debug_ripng_events_cmd); -  install_element (CONFIG_NODE, &no_debug_ripng_packet_cmd); -  install_element (CONFIG_NODE, &no_debug_ripng_packet_direct_cmd); -  install_element (CONFIG_NODE, &no_debug_ripng_zebra_cmd); +	ripng_debug_event = 0; +	ripng_debug_packet = 0; +	ripng_debug_zebra = 0; + +	install_node(&debug_node, config_write_debug); + +	install_element(VIEW_NODE, &show_debugging_ripng_cmd); + +	install_element(ENABLE_NODE, &debug_ripng_events_cmd); +	install_element(ENABLE_NODE, &debug_ripng_packet_cmd); +	install_element(ENABLE_NODE, &debug_ripng_packet_direct_cmd); +	install_element(ENABLE_NODE, &debug_ripng_zebra_cmd); +	install_element(ENABLE_NODE, &no_debug_ripng_events_cmd); +	install_element(ENABLE_NODE, &no_debug_ripng_packet_cmd); +	install_element(ENABLE_NODE, &no_debug_ripng_packet_direct_cmd); +	install_element(ENABLE_NODE, &no_debug_ripng_zebra_cmd); + +	install_element(CONFIG_NODE, &debug_ripng_events_cmd); +	install_element(CONFIG_NODE, &debug_ripng_packet_cmd); +	install_element(CONFIG_NODE, &debug_ripng_packet_direct_cmd); +	install_element(CONFIG_NODE, &debug_ripng_zebra_cmd); +	install_element(CONFIG_NODE, &no_debug_ripng_events_cmd); +	install_element(CONFIG_NODE, &no_debug_ripng_packet_cmd); +	install_element(CONFIG_NODE, &no_debug_ripng_packet_direct_cmd); +	install_element(CONFIG_NODE, &no_debug_ripng_zebra_cmd);  } diff --git a/ripngd/ripng_debug.h b/ripngd/ripng_debug.h index b4e1455ad7..8124a1a0c9 100644 --- a/ripngd/ripng_debug.h +++ b/ripngd/ripng_debug.h @@ -44,7 +44,7 @@ extern unsigned long ripng_debug_event;  extern unsigned long ripng_debug_packet;  extern unsigned long ripng_debug_zebra; -extern void ripng_debug_init (void); -extern void ripng_debug_reset (void); +extern void ripng_debug_init(void); +extern void ripng_debug_reset(void);  #endif /* _ZEBRA_RIPNG_DEBUG_H */ diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c index e4b45c54af..c762d8ace7 100644 --- a/ripngd/ripng_interface.c +++ b/ripngd/ripng_interface.c @@ -50,439 +50,431 @@  extern struct zebra_privs_t ripngd_privs;  /* Static utility function. */ -static void ripng_enable_apply (struct interface *); -static void ripng_passive_interface_apply (struct interface *); -static int ripng_enable_if_lookup (const char *); -static int ripng_enable_network_lookup2 (struct connected *); -static void ripng_enable_apply_all (void); +static void ripng_enable_apply(struct interface *); +static void ripng_passive_interface_apply(struct interface *); +static int ripng_enable_if_lookup(const char *); +static int ripng_enable_network_lookup2(struct connected *); +static void ripng_enable_apply_all(void);  /* Join to the all rip routers multicast group. */ -static int -ripng_multicast_join (struct interface *ifp) +static int ripng_multicast_join(struct interface *ifp)  { -  int ret; -  struct ipv6_mreq mreq; -  int save_errno; - -  if (if_is_multicast (ifp)) { -    memset (&mreq, 0, sizeof (mreq)); -    inet_pton(AF_INET6, RIPNG_GROUP, &mreq.ipv6mr_multiaddr); -    mreq.ipv6mr_interface = ifp->ifindex; - -    /* -     * NetBSD 1.6.2 requires root to join groups on gif(4). -     * While this is bogus, privs are available and easy to use -     * for this call as a workaround. -     */ -    if (ripngd_privs.change (ZPRIVS_RAISE)) -      zlog_err ("ripng_multicast_join: could not raise privs"); - -    ret = setsockopt (ripng->sock, IPPROTO_IPV6, IPV6_JOIN_GROUP, -		      (char *) &mreq, sizeof (mreq)); -    save_errno = errno; - -    if (ripngd_privs.change (ZPRIVS_LOWER)) -      zlog_err ("ripng_multicast_join: could not lower privs"); - -    if (ret < 0 && save_errno == EADDRINUSE) -      { -	/* -	 * Group is already joined.  This occurs due to sloppy group -	 * management, in particular declining to leave the group on -	 * an interface that has just gone down. -	 */ -	zlog_warn ("ripng join on %s EADDRINUSE (ignoring)\n", ifp->name); -	return 0;		/* not an error */ -      } - -    if (ret < 0) -      zlog_warn ("can't setsockopt IPV6_JOIN_GROUP: %s", -      		 safe_strerror (save_errno)); - -    if (IS_RIPNG_DEBUG_EVENT) -      zlog_debug ("RIPng %s join to all-rip-routers multicast group", ifp->name); - -    if (ret < 0) -      return -1; -  } -  return 0; +	int ret; +	struct ipv6_mreq mreq; +	int save_errno; + +	if (if_is_multicast(ifp)) { +		memset(&mreq, 0, sizeof(mreq)); +		inet_pton(AF_INET6, RIPNG_GROUP, &mreq.ipv6mr_multiaddr); +		mreq.ipv6mr_interface = ifp->ifindex; + +		/* +		 * NetBSD 1.6.2 requires root to join groups on gif(4). +		 * While this is bogus, privs are available and easy to use +		 * for this call as a workaround. +		 */ +		if (ripngd_privs.change(ZPRIVS_RAISE)) +			zlog_err("ripng_multicast_join: could not raise privs"); + +		ret = setsockopt(ripng->sock, IPPROTO_IPV6, IPV6_JOIN_GROUP, +				 (char *)&mreq, sizeof(mreq)); +		save_errno = errno; + +		if (ripngd_privs.change(ZPRIVS_LOWER)) +			zlog_err("ripng_multicast_join: could not lower privs"); + +		if (ret < 0 && save_errno == EADDRINUSE) { +			/* +			 * Group is already joined.  This occurs due to sloppy +			 * group +			 * management, in particular declining to leave the +			 * group on +			 * an interface that has just gone down. +			 */ +			zlog_warn("ripng join on %s EADDRINUSE (ignoring)\n", +				  ifp->name); +			return 0; /* not an error */ +		} + +		if (ret < 0) +			zlog_warn("can't setsockopt IPV6_JOIN_GROUP: %s", +				  safe_strerror(save_errno)); + +		if (IS_RIPNG_DEBUG_EVENT) +			zlog_debug( +				"RIPng %s join to all-rip-routers multicast group", +				ifp->name); + +		if (ret < 0) +			return -1; +	} +	return 0;  }  /* Leave from the all rip routers multicast group. */ -static int -ripng_multicast_leave (struct interface *ifp) +static int ripng_multicast_leave(struct interface *ifp)  { -  int ret; -  struct ipv6_mreq mreq; - -  if (if_is_multicast (ifp)) { -    memset (&mreq, 0, sizeof (mreq)); -    inet_pton(AF_INET6, RIPNG_GROUP, &mreq.ipv6mr_multiaddr); -    mreq.ipv6mr_interface = ifp->ifindex; - -    ret = setsockopt (ripng->sock, IPPROTO_IPV6, IPV6_LEAVE_GROUP, -		      (char *) &mreq, sizeof (mreq)); -    if (ret < 0) -      zlog_warn ("can't setsockopt IPV6_LEAVE_GROUP: %s\n", safe_strerror (errno)); - -    if (IS_RIPNG_DEBUG_EVENT) -      zlog_debug ("RIPng %s leave from all-rip-routers multicast group", -	         ifp->name); - -    if (ret < 0) -      return -1; -  } +	int ret; +	struct ipv6_mreq mreq; + +	if (if_is_multicast(ifp)) { +		memset(&mreq, 0, sizeof(mreq)); +		inet_pton(AF_INET6, RIPNG_GROUP, &mreq.ipv6mr_multiaddr); +		mreq.ipv6mr_interface = ifp->ifindex; + +		ret = setsockopt(ripng->sock, IPPROTO_IPV6, IPV6_LEAVE_GROUP, +				 (char *)&mreq, sizeof(mreq)); +		if (ret < 0) +			zlog_warn("can't setsockopt IPV6_LEAVE_GROUP: %s\n", +				  safe_strerror(errno)); + +		if (IS_RIPNG_DEBUG_EVENT) +			zlog_debug( +				"RIPng %s leave from all-rip-routers multicast group", +				ifp->name); + +		if (ret < 0) +			return -1; +	} -  return 0; +	return 0;  }  /* How many link local IPv6 address could be used on the interface ? */ -static int -ripng_if_ipv6_lladdress_check (struct interface *ifp) +static int ripng_if_ipv6_lladdress_check(struct interface *ifp)  { -  struct listnode *nn; -  struct connected *connected; -  int count = 0; +	struct listnode *nn; +	struct connected *connected; +	int count = 0; -  for (ALL_LIST_ELEMENTS_RO (ifp->connected, nn, connected)) -    { -      struct prefix *p; -      p = connected->address; +	for (ALL_LIST_ELEMENTS_RO(ifp->connected, nn, connected)) { +		struct prefix *p; +		p = connected->address; -      if ((p->family == AF_INET6) && -          IN6_IS_ADDR_LINKLOCAL (&p->u.prefix6)) -        count++; -    } +		if ((p->family == AF_INET6) +		    && IN6_IS_ADDR_LINKLOCAL(&p->u.prefix6)) +			count++; +	} -  return count; +	return count;  } -static int -ripng_if_down (struct interface *ifp) +static int ripng_if_down(struct interface *ifp)  { -  struct route_node *rp; -  struct ripng_info *rinfo; -  struct ripng_interface *ri; -  struct list *list = NULL; -  struct listnode *listnode = NULL, *nextnode = NULL; - -  if (ripng) -    for (rp = route_top (ripng->table); rp; rp = route_next (rp)) -      if ((list = rp->info) != NULL) -        for (ALL_LIST_ELEMENTS (list, listnode, nextnode, rinfo)) -          if (rinfo->ifindex == ifp->ifindex) -            ripng_ecmp_delete (rinfo); - -  ri = ifp->info; -   -  if (ri->running) -   { -     if (IS_RIPNG_DEBUG_EVENT) -       zlog_debug ("turn off %s", ifp->name); - -     /* Leave from multicast group. */ -     ripng_multicast_leave (ifp); - -     ri->running = 0; -   } - -  return 0; +	struct route_node *rp; +	struct ripng_info *rinfo; +	struct ripng_interface *ri; +	struct list *list = NULL; +	struct listnode *listnode = NULL, *nextnode = NULL; + +	if (ripng) +		for (rp = route_top(ripng->table); rp; rp = route_next(rp)) +			if ((list = rp->info) != NULL) +				for (ALL_LIST_ELEMENTS(list, listnode, nextnode, +						       rinfo)) +					if (rinfo->ifindex == ifp->ifindex) +						ripng_ecmp_delete(rinfo); + +	ri = ifp->info; + +	if (ri->running) { +		if (IS_RIPNG_DEBUG_EVENT) +			zlog_debug("turn off %s", ifp->name); + +		/* Leave from multicast group. */ +		ripng_multicast_leave(ifp); + +		ri->running = 0; +	} + +	return 0;  }  /* Inteface link up message processing. */ -int -ripng_interface_up (int command, struct zclient *zclient, zebra_size_t length, -    vrf_id_t vrf_id) +int ripng_interface_up(int command, struct zclient *zclient, +		       zebra_size_t length, vrf_id_t vrf_id)  { -  struct stream *s; -  struct interface *ifp; +	struct stream *s; +	struct interface *ifp; -  /* zebra_interface_state_read() updates interface structure in iflist. */ -  s = zclient->ibuf; -  ifp = zebra_interface_state_read (s, vrf_id); +	/* zebra_interface_state_read() updates interface structure in iflist. +	 */ +	s = zclient->ibuf; +	ifp = zebra_interface_state_read(s, vrf_id); -  if (ifp == NULL) -    return 0; +	if (ifp == NULL) +		return 0; -  if (IS_RIPNG_DEBUG_ZEBRA) -    zlog_debug ("interface up %s index %d flags %llx metric %d mtu %d", -	       ifp->name, ifp->ifindex, (unsigned long long)ifp->flags, -	       ifp->metric, ifp->mtu6); +	if (IS_RIPNG_DEBUG_ZEBRA) +		zlog_debug( +			"interface up %s index %d flags %llx metric %d mtu %d", +			ifp->name, ifp->ifindex, (unsigned long long)ifp->flags, +			ifp->metric, ifp->mtu6); -  /* Check if this interface is RIPng enabled or not. */ -  ripng_enable_apply (ifp); +	/* Check if this interface is RIPng enabled or not. */ +	ripng_enable_apply(ifp); -  /* Check for a passive interface. */ -  ripng_passive_interface_apply (ifp); +	/* Check for a passive interface. */ +	ripng_passive_interface_apply(ifp); -  /* Apply distribute list to the all interface. */ -  ripng_distribute_update_interface (ifp); +	/* Apply distribute list to the all interface. */ +	ripng_distribute_update_interface(ifp); -  return 0; +	return 0;  }  /* Inteface link down message processing. */ -int -ripng_interface_down (int command, struct zclient *zclient, -		      zebra_size_t length, vrf_id_t vrf_id) +int ripng_interface_down(int command, struct zclient *zclient, +			 zebra_size_t length, vrf_id_t vrf_id)  { -  struct stream *s; -  struct interface *ifp; +	struct stream *s; +	struct interface *ifp; -  /* zebra_interface_state_read() updates interface structure in iflist. */ -  s = zclient->ibuf; -  ifp = zebra_interface_state_read (s, vrf_id); +	/* zebra_interface_state_read() updates interface structure in iflist. +	 */ +	s = zclient->ibuf; +	ifp = zebra_interface_state_read(s, vrf_id); -  if (ifp == NULL) -    return 0; +	if (ifp == NULL) +		return 0; -  ripng_if_down (ifp); +	ripng_if_down(ifp); -  if (IS_RIPNG_DEBUG_ZEBRA) -    zlog_debug ("interface down %s index %d flags %#llx metric %d mtu %d", -		ifp->name, ifp->ifindex, -		(unsigned long long) ifp->flags, ifp->metric, ifp->mtu6); +	if (IS_RIPNG_DEBUG_ZEBRA) +		zlog_debug( +			"interface down %s index %d flags %#llx metric %d mtu %d", +			ifp->name, ifp->ifindex, (unsigned long long)ifp->flags, +			ifp->metric, ifp->mtu6); -  return 0; +	return 0;  }  /* Inteface addition message from zebra. */ -int -ripng_interface_add (int command, struct zclient *zclient, zebra_size_t length, -    vrf_id_t vrf_id) +int ripng_interface_add(int command, struct zclient *zclient, +			zebra_size_t length, vrf_id_t vrf_id)  { -  struct interface *ifp; +	struct interface *ifp; -  ifp = zebra_interface_add_read (zclient->ibuf, vrf_id); +	ifp = zebra_interface_add_read(zclient->ibuf, vrf_id); -  if (IS_RIPNG_DEBUG_ZEBRA) -    zlog_debug ("RIPng interface add %s index %d flags %#llx metric %d mtu %d", -		ifp->name, ifp->ifindex, (unsigned long long) ifp->flags, -		ifp->metric, ifp->mtu6); +	if (IS_RIPNG_DEBUG_ZEBRA) +		zlog_debug( +			"RIPng interface add %s index %d flags %#llx metric %d mtu %d", +			ifp->name, ifp->ifindex, (unsigned long long)ifp->flags, +			ifp->metric, ifp->mtu6); -  /* Check is this interface is RIP enabled or not.*/ -  ripng_enable_apply (ifp); +	/* Check is this interface is RIP enabled or not.*/ +	ripng_enable_apply(ifp); -  /* Apply distribute list to the interface. */ -  ripng_distribute_update_interface (ifp); +	/* Apply distribute list to the interface. */ +	ripng_distribute_update_interface(ifp); -  /* Check interface routemap. */ -  ripng_if_rmap_update_interface (ifp); +	/* Check interface routemap. */ +	ripng_if_rmap_update_interface(ifp); -  return 0; +	return 0;  } -int -ripng_interface_delete (int command, struct zclient *zclient, -			zebra_size_t length, vrf_id_t vrf_id) +int ripng_interface_delete(int command, struct zclient *zclient, +			   zebra_size_t length, vrf_id_t vrf_id)  { -  struct interface *ifp; -  struct stream *s; +	struct interface *ifp; +	struct stream *s; -  s = zclient->ibuf; -  /*  zebra_interface_state_read() updates interface structure in iflist */ -  ifp = zebra_interface_state_read (s, vrf_id); +	s = zclient->ibuf; +	/*  zebra_interface_state_read() updates interface structure in iflist +	 */ +	ifp = zebra_interface_state_read(s, vrf_id); -  if (ifp == NULL) -    return 0; +	if (ifp == NULL) +		return 0; -  if (if_is_up (ifp)) { -    ripng_if_down(ifp); -  } +	if (if_is_up(ifp)) { +		ripng_if_down(ifp); +	} -  zlog_info("interface delete %s index %d flags %#llx metric %d mtu %d", -            ifp->name, ifp->ifindex, (unsigned long long) ifp->flags, -	    ifp->metric, ifp->mtu6); +	zlog_info("interface delete %s index %d flags %#llx metric %d mtu %d", +		  ifp->name, ifp->ifindex, (unsigned long long)ifp->flags, +		  ifp->metric, ifp->mtu6); -  /* To support pseudo interface do not free interface structure.  */ -  /* if_delete(ifp); */ -  ifp->ifindex = IFINDEX_DELETED; +	/* To support pseudo interface do not free interface structure.  */ +	/* if_delete(ifp); */ +	ifp->ifindex = IFINDEX_DELETED; -  return 0; +	return 0;  } -void -ripng_interface_clean (void) +void ripng_interface_clean(void)  { -  struct listnode *node, *nnode; -  struct interface *ifp; -  struct ripng_interface *ri; - -  for (ALL_LIST_ELEMENTS (vrf_iflist (VRF_DEFAULT), node, nnode, ifp)) -    { -      ri = ifp->info; - -      ri->enable_network = 0; -      ri->enable_interface = 0; -      ri->running = 0; - -      if (ri->t_wakeup) -        { -          thread_cancel (ri->t_wakeup); -          ri->t_wakeup = NULL; -        } -    } -} +	struct listnode *node, *nnode; +	struct interface *ifp; +	struct ripng_interface *ri; -void -ripng_interface_reset (void) -{ -  struct listnode *node; -  struct interface *ifp; -  struct ripng_interface *ri; - -  for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) -    { -      ri = ifp->info; - -      ri->enable_network = 0; -      ri->enable_interface = 0; -      ri->running = 0; +	for (ALL_LIST_ELEMENTS(vrf_iflist(VRF_DEFAULT), node, nnode, ifp)) { +		ri = ifp->info; -      ri->split_horizon = RIPNG_NO_SPLIT_HORIZON; -      ri->split_horizon_default = RIPNG_NO_SPLIT_HORIZON; +		ri->enable_network = 0; +		ri->enable_interface = 0; +		ri->running = 0; -      ri->list[RIPNG_FILTER_IN] = NULL; -      ri->list[RIPNG_FILTER_OUT] = NULL; - -      ri->prefix[RIPNG_FILTER_IN] = NULL; -      ri->prefix[RIPNG_FILTER_OUT] = NULL; +		if (ri->t_wakeup) { +			thread_cancel(ri->t_wakeup); +			ri->t_wakeup = NULL; +		} +	} +} -      if (ri->t_wakeup) -        { -          thread_cancel (ri->t_wakeup); -          ri->t_wakeup = NULL; -        } +void ripng_interface_reset(void) +{ +	struct listnode *node; +	struct interface *ifp; +	struct ripng_interface *ri; -      ri->passive = 0; -    } -} +	for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) { +		ri = ifp->info; -static void -ripng_apply_address_add (struct connected *ifc) { -  struct prefix_ipv6 address; -  struct prefix *p; +		ri->enable_network = 0; +		ri->enable_interface = 0; +		ri->running = 0; -  if (!ripng) -    return; +		ri->split_horizon = RIPNG_NO_SPLIT_HORIZON; +		ri->split_horizon_default = RIPNG_NO_SPLIT_HORIZON; -  if (! if_is_up(ifc->ifp)) -    return; +		ri->list[RIPNG_FILTER_IN] = NULL; +		ri->list[RIPNG_FILTER_OUT] = NULL; -  p = ifc->address; +		ri->prefix[RIPNG_FILTER_IN] = NULL; +		ri->prefix[RIPNG_FILTER_OUT] = NULL; -  memset (&address, 0, sizeof (address)); -  address.family = p->family; -  address.prefix = p->u.prefix6; -  address.prefixlen = p->prefixlen; -  apply_mask_ipv6(&address); +		if (ri->t_wakeup) { +			thread_cancel(ri->t_wakeup); +			ri->t_wakeup = NULL; +		} -  /* Check if this interface is RIP enabled or not -     or  Check if this address's prefix is RIP enabled */ -  if ((ripng_enable_if_lookup(ifc->ifp->name) >= 0) || -      (ripng_enable_network_lookup2(ifc) >= 0)) -    ripng_redistribute_add(ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE, -                           &address, ifc->ifp->ifindex, NULL, 0); +		ri->passive = 0; +	} +} +static void ripng_apply_address_add(struct connected *ifc) +{ +	struct prefix_ipv6 address; +	struct prefix *p; + +	if (!ripng) +		return; + +	if (!if_is_up(ifc->ifp)) +		return; + +	p = ifc->address; + +	memset(&address, 0, sizeof(address)); +	address.family = p->family; +	address.prefix = p->u.prefix6; +	address.prefixlen = p->prefixlen; +	apply_mask_ipv6(&address); + +	/* Check if this interface is RIP enabled or not +	   or  Check if this address's prefix is RIP enabled */ +	if ((ripng_enable_if_lookup(ifc->ifp->name) >= 0) +	    || (ripng_enable_network_lookup2(ifc) >= 0)) +		ripng_redistribute_add(ZEBRA_ROUTE_CONNECT, +				       RIPNG_ROUTE_INTERFACE, &address, +				       ifc->ifp->ifindex, NULL, 0);  } -int -ripng_interface_address_add (int command, struct zclient *zclient, -			     zebra_size_t length, vrf_id_t vrf_id) +int ripng_interface_address_add(int command, struct zclient *zclient, +				zebra_size_t length, vrf_id_t vrf_id)  { -  struct connected *c; -  struct prefix *p; +	struct connected *c; +	struct prefix *p; -  c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD,  -                                    zclient->ibuf, vrf_id); +	c = zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_ADD, +					 zclient->ibuf, vrf_id); -  if (c == NULL) -    return 0; +	if (c == NULL) +		return 0; -  p = c->address; +	p = c->address; -  if (p->family == AF_INET6) -    { -      struct ripng_interface *ri = c->ifp->info; -       -      if (IS_RIPNG_DEBUG_ZEBRA) -	zlog_debug ("RIPng connected address %s/%d add", -		   inet6_ntoa(p->u.prefix6), -		   p->prefixlen); -       -      /* Check is this prefix needs to be redistributed. */ -      ripng_apply_address_add(c); +	if (p->family == AF_INET6) { +		struct ripng_interface *ri = c->ifp->info; -      /* Let's try once again whether the interface could be activated */ -      if (!ri->running) { -        /* Check if this interface is RIP enabled or not.*/ -        ripng_enable_apply (c->ifp); +		if (IS_RIPNG_DEBUG_ZEBRA) +			zlog_debug("RIPng connected address %s/%d add", +				   inet6_ntoa(p->u.prefix6), p->prefixlen); -        /* Apply distribute list to the interface. */ -        ripng_distribute_update_interface (c->ifp); +		/* Check is this prefix needs to be redistributed. */ +		ripng_apply_address_add(c); -        /* Check interface routemap. */ -        ripng_if_rmap_update_interface (c->ifp); -      } +		/* Let's try once again whether the interface could be activated +		 */ +		if (!ri->running) { +			/* Check if this interface is RIP enabled or not.*/ +			ripng_enable_apply(c->ifp); -    } +			/* Apply distribute list to the interface. */ +			ripng_distribute_update_interface(c->ifp); -  return 0; +			/* Check interface routemap. */ +			ripng_if_rmap_update_interface(c->ifp); +		} +	} + +	return 0;  } -static void -ripng_apply_address_del (struct connected *ifc) { -  struct prefix_ipv6 address; -  struct prefix *p; +static void ripng_apply_address_del(struct connected *ifc) +{ +	struct prefix_ipv6 address; +	struct prefix *p; -  if (!ripng) -    return; +	if (!ripng) +		return; -  if (! if_is_up(ifc->ifp)) -    return; +	if (!if_is_up(ifc->ifp)) +		return; -  p = ifc->address; +	p = ifc->address; -  memset (&address, 0, sizeof (address)); -  address.family = p->family; -  address.prefix = p->u.prefix6; -  address.prefixlen = p->prefixlen; -  apply_mask_ipv6(&address); +	memset(&address, 0, sizeof(address)); +	address.family = p->family; +	address.prefix = p->u.prefix6; +	address.prefixlen = p->prefixlen; +	apply_mask_ipv6(&address); -  ripng_redistribute_delete(ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE, -                            &address, ifc->ifp->ifindex); +	ripng_redistribute_delete(ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE, +				  &address, ifc->ifp->ifindex);  } -int -ripng_interface_address_delete (int command, struct zclient *zclient, -				zebra_size_t length, vrf_id_t vrf_id) +int ripng_interface_address_delete(int command, struct zclient *zclient, +				   zebra_size_t length, vrf_id_t vrf_id)  { -  struct connected *ifc; -  struct prefix *p; -  char buf[INET6_ADDRSTRLEN]; - -  ifc = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE,  -                                      zclient->ibuf, vrf_id); -   -  if (ifc) -    { -      p = ifc->address; - -      if (p->family == AF_INET6) -	{ -	  if (IS_RIPNG_DEBUG_ZEBRA) -	    zlog_debug ("RIPng connected address %s/%d delete", -		       inet_ntop (AF_INET6, &p->u.prefix6, buf, -				  INET6_ADDRSTRLEN), -		       p->prefixlen); - -	  /* Check wether this prefix needs to be removed. */ -	  ripng_apply_address_del(ifc); +	struct connected *ifc; +	struct prefix *p; +	char buf[INET6_ADDRSTRLEN]; + +	ifc = zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_DELETE, +					   zclient->ibuf, vrf_id); + +	if (ifc) { +		p = ifc->address; + +		if (p->family == AF_INET6) { +			if (IS_RIPNG_DEBUG_ZEBRA) +				zlog_debug( +					"RIPng connected address %s/%d delete", +					inet_ntop(AF_INET6, &p->u.prefix6, buf, +						  INET6_ADDRSTRLEN), +					p->prefixlen); + +			/* Check wether this prefix needs to be removed. */ +			ripng_apply_address_del(ifc); +		} +		connected_free(ifc);  	} -      connected_free (ifc); -    } -  return 0; +	return 0;  }  /* RIPng enable interface vector. */ @@ -494,449 +486,426 @@ struct route_table *ripng_enable_network;  /* Lookup RIPng enable network. */  /* Check wether the interface has at least a connected prefix that   * is within the ripng_enable_network table. */ -static int -ripng_enable_network_lookup_if (struct interface *ifp) +static int ripng_enable_network_lookup_if(struct interface *ifp)  { -  struct listnode *node; -  struct connected *connected; -  struct prefix_ipv6 address; - -  for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected)) -    { -      struct prefix *p;  -      struct route_node *node; - -      p = connected->address; - -      if (p->family == AF_INET6) -        { -          address.family = AF_INET6; -          address.prefix = p->u.prefix6; -          address.prefixlen = IPV6_MAX_BITLEN; - -          node = route_node_match (ripng_enable_network, -                                   (struct prefix *)&address); -          if (node) -            { -              route_unlock_node (node); -              return 1; -            } -        } -    } -  return -1; +	struct listnode *node; +	struct connected *connected; +	struct prefix_ipv6 address; + +	for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, connected)) { +		struct prefix *p; +		struct route_node *node; + +		p = connected->address; + +		if (p->family == AF_INET6) { +			address.family = AF_INET6; +			address.prefix = p->u.prefix6; +			address.prefixlen = IPV6_MAX_BITLEN; + +			node = route_node_match(ripng_enable_network, +						(struct prefix *)&address); +			if (node) { +				route_unlock_node(node); +				return 1; +			} +		} +	} +	return -1;  }  /* Check wether connected is within the ripng_enable_network table. */ -static int -ripng_enable_network_lookup2 (struct connected *connected) +static int ripng_enable_network_lookup2(struct connected *connected)  { -  struct prefix_ipv6 address; -  struct prefix *p; +	struct prefix_ipv6 address; +	struct prefix *p; -  p = connected->address; +	p = connected->address; -  if (p->family == AF_INET6) { -    struct route_node *node; +	if (p->family == AF_INET6) { +		struct route_node *node; -    address.family = p->family; -    address.prefix = p->u.prefix6; -    address.prefixlen = IPV6_MAX_BITLEN; +		address.family = p->family; +		address.prefix = p->u.prefix6; +		address.prefixlen = IPV6_MAX_BITLEN; -    /* LPM on p->family, p->u.prefix6/IPV6_MAX_BITLEN within ripng_enable_network */ -    node = route_node_match (ripng_enable_network, -                             (struct prefix *)&address); +		/* LPM on p->family, p->u.prefix6/IPV6_MAX_BITLEN within +		 * ripng_enable_network */ +		node = route_node_match(ripng_enable_network, +					(struct prefix *)&address); -    if (node) { -      route_unlock_node (node); -      return 1; -    } -  } +		if (node) { +			route_unlock_node(node); +			return 1; +		} +	} -  return -1; +	return -1;  }  /* Add RIPng enable network. */ -static int -ripng_enable_network_add (struct prefix *p) +static int ripng_enable_network_add(struct prefix *p)  { -  struct route_node *node; +	struct route_node *node; -  node = route_node_get (ripng_enable_network, p); +	node = route_node_get(ripng_enable_network, p); -  if (node->info) -    { -      route_unlock_node (node); -      return -1; -    } -  else -    node->info = (void *)1; +	if (node->info) { +		route_unlock_node(node); +		return -1; +	} else +		node->info = (void *)1; -  /* XXX: One should find a better solution than a generic one */ -  ripng_enable_apply_all(); +	/* XXX: One should find a better solution than a generic one */ +	ripng_enable_apply_all(); -  return 1; +	return 1;  }  /* Delete RIPng enable network. */ -static int -ripng_enable_network_delete (struct prefix *p) +static int ripng_enable_network_delete(struct prefix *p)  { -  struct route_node *node; +	struct route_node *node; -  node = route_node_lookup (ripng_enable_network, p); -  if (node) -    { -      node->info = NULL; +	node = route_node_lookup(ripng_enable_network, p); +	if (node) { +		node->info = NULL; -      /* Unlock info lock. */ -      route_unlock_node (node); +		/* Unlock info lock. */ +		route_unlock_node(node); -      /* Unlock lookup lock. */ -      route_unlock_node (node); +		/* Unlock lookup lock. */ +		route_unlock_node(node); -      return 1; -    } -  return -1; +		return 1; +	} +	return -1;  }  /* Lookup function. */ -static int -ripng_enable_if_lookup (const char *ifname) +static int ripng_enable_if_lookup(const char *ifname)  { -  unsigned int i; -  char *str; - -  for (i = 0; i < vector_active (ripng_enable_if); i++) -    if ((str = vector_slot (ripng_enable_if, i)) != NULL) -      if (strcmp (str, ifname) == 0) -	return i; -  return -1; +	unsigned int i; +	char *str; + +	for (i = 0; i < vector_active(ripng_enable_if); i++) +		if ((str = vector_slot(ripng_enable_if, i)) != NULL) +			if (strcmp(str, ifname) == 0) +				return i; +	return -1;  }  /* Add interface to ripng_enable_if. */ -static int -ripng_enable_if_add (const char *ifname) +static int ripng_enable_if_add(const char *ifname)  { -  int ret; +	int ret; -  ret = ripng_enable_if_lookup (ifname); -  if (ret >= 0) -    return -1; +	ret = ripng_enable_if_lookup(ifname); +	if (ret >= 0) +		return -1; -  vector_set (ripng_enable_if, strdup (ifname)); +	vector_set(ripng_enable_if, strdup(ifname)); -  ripng_enable_apply_all(); +	ripng_enable_apply_all(); -  return 1; +	return 1;  }  /* Delete interface from ripng_enable_if. */ -static int -ripng_enable_if_delete (const char *ifname) +static int ripng_enable_if_delete(const char *ifname)  { -  int index; -  char *str; +	int index; +	char *str; -  index = ripng_enable_if_lookup (ifname); -  if (index < 0) -    return -1; +	index = ripng_enable_if_lookup(ifname); +	if (index < 0) +		return -1; -  str = vector_slot (ripng_enable_if, index); -  free (str); -  vector_unset (ripng_enable_if, index); +	str = vector_slot(ripng_enable_if, index); +	free(str); +	vector_unset(ripng_enable_if, index); -  ripng_enable_apply_all(); +	ripng_enable_apply_all(); -  return 1; +	return 1;  }  /* Wake up interface. */ -static int -ripng_interface_wakeup (struct thread *t) +static int ripng_interface_wakeup(struct thread *t)  { -  struct interface *ifp; -  struct ripng_interface *ri; +	struct interface *ifp; +	struct ripng_interface *ri; -  /* Get interface. */ -  ifp = THREAD_ARG (t); +	/* Get interface. */ +	ifp = THREAD_ARG(t); -  ri = ifp->info; -  ri->t_wakeup = NULL; +	ri = ifp->info; +	ri->t_wakeup = NULL; -  /* Join to multicast group. */ -  if (ripng_multicast_join (ifp) < 0) { -    zlog_err ("multicast join failed, interface %s not running", ifp->name); -    return 0; -  } -     -  /* Set running flag. */ -  ri->running = 1; +	/* Join to multicast group. */ +	if (ripng_multicast_join(ifp) < 0) { +		zlog_err("multicast join failed, interface %s not running", +			 ifp->name); +		return 0; +	} + +	/* Set running flag. */ +	ri->running = 1; -  /* Send RIP request to the interface. */ -  ripng_request (ifp); +	/* Send RIP request to the interface. */ +	ripng_request(ifp); -  return 0; +	return 0;  } -static void -ripng_connect_set (struct interface *ifp, int set) +static void ripng_connect_set(struct interface *ifp, int set)  { -  struct listnode *node, *nnode; -  struct connected *connected; -  struct prefix_ipv6 address; - -  for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, connected)) -    { -      struct prefix *p; -      p = connected->address; - -      if (p->family != AF_INET6) -        continue; - -      address.family = AF_INET6; -      address.prefix = p->u.prefix6; -      address.prefixlen = p->prefixlen; -      apply_mask_ipv6 (&address); - -      if (set) { -        /* Check once more wether this prefix is within a "network IF_OR_PREF" one */ -        if ((ripng_enable_if_lookup(connected->ifp->name) >= 0) || -            (ripng_enable_network_lookup2(connected) >= 0)) -          ripng_redistribute_add (ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE, -                                  &address, connected->ifp->ifindex, NULL, 0); -      } else { -        ripng_redistribute_delete (ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE, -                                   &address, connected->ifp->ifindex); -        if (ripng_redistribute_check (ZEBRA_ROUTE_CONNECT)) -          ripng_redistribute_add (ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_REDISTRIBUTE, -                                  &address, connected->ifp->ifindex, NULL, 0); -      } -    } +	struct listnode *node, *nnode; +	struct connected *connected; +	struct prefix_ipv6 address; + +	for (ALL_LIST_ELEMENTS(ifp->connected, node, nnode, connected)) { +		struct prefix *p; +		p = connected->address; + +		if (p->family != AF_INET6) +			continue; + +		address.family = AF_INET6; +		address.prefix = p->u.prefix6; +		address.prefixlen = p->prefixlen; +		apply_mask_ipv6(&address); + +		if (set) { +			/* Check once more wether this prefix is within a +			 * "network IF_OR_PREF" one */ +			if ((ripng_enable_if_lookup(connected->ifp->name) >= 0) +			    || (ripng_enable_network_lookup2(connected) >= 0)) +				ripng_redistribute_add( +					ZEBRA_ROUTE_CONNECT, +					RIPNG_ROUTE_INTERFACE, &address, +					connected->ifp->ifindex, NULL, 0); +		} else { +			ripng_redistribute_delete( +				ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE, +				&address, connected->ifp->ifindex); +			if (ripng_redistribute_check(ZEBRA_ROUTE_CONNECT)) +				ripng_redistribute_add( +					ZEBRA_ROUTE_CONNECT, +					RIPNG_ROUTE_REDISTRIBUTE, &address, +					connected->ifp->ifindex, NULL, 0); +		} +	}  }  /* Check RIPng is enabed on this interface. */ -void -ripng_enable_apply (struct interface *ifp) +void ripng_enable_apply(struct interface *ifp)  { -  int ret; -  struct ripng_interface *ri = NULL; - -  /* Check interface. */ -  if (! if_is_up (ifp)) -    return; -   -  ri = ifp->info; - -  /* Is this interface a candidate for RIPng ? */ -  ret = ripng_enable_network_lookup_if (ifp); - -  /* If the interface is matched. */ -  if (ret > 0) -    ri->enable_network = 1; -  else -    ri->enable_network = 0; - -  /* Check interface name configuration. */ -  ret = ripng_enable_if_lookup (ifp->name); -  if (ret >= 0) -    ri->enable_interface = 1; -  else -    ri->enable_interface = 0; - -  /* any candidate interface MUST have a link-local IPv6 address */ -  if ((! ripng_if_ipv6_lladdress_check (ifp)) && -      (ri->enable_network || ri->enable_interface)) { -    ri->enable_network = 0; -    ri->enable_interface = 0; -    zlog_warn("Interface %s does not have any link-local address", -              ifp->name); -  } - -  /* Update running status of the interface. */ -  if (ri->enable_network || ri->enable_interface) -    { -      zlog_info ("RIPng INTERFACE ON %s", ifp->name); - -      /* Add interface wake up thread. */ -      thread_add_timer(master, ripng_interface_wakeup, ifp, 1, -		       &ri->t_wakeup); - -      ripng_connect_set (ifp, 1); -    } -  else -    { -      if (ri->running) -	{ -	  /* Might as well clean up the route table as well -	   * ripng_if_down sets to 0 ri->running, and displays "turn off %s" -	   **/ -	  ripng_if_down(ifp); - -	  ripng_connect_set (ifp, 0); +	int ret; +	struct ripng_interface *ri = NULL; + +	/* Check interface. */ +	if (!if_is_up(ifp)) +		return; + +	ri = ifp->info; + +	/* Is this interface a candidate for RIPng ? */ +	ret = ripng_enable_network_lookup_if(ifp); + +	/* If the interface is matched. */ +	if (ret > 0) +		ri->enable_network = 1; +	else +		ri->enable_network = 0; + +	/* Check interface name configuration. */ +	ret = ripng_enable_if_lookup(ifp->name); +	if (ret >= 0) +		ri->enable_interface = 1; +	else +		ri->enable_interface = 0; + +	/* any candidate interface MUST have a link-local IPv6 address */ +	if ((!ripng_if_ipv6_lladdress_check(ifp)) +	    && (ri->enable_network || ri->enable_interface)) { +		ri->enable_network = 0; +		ri->enable_interface = 0; +		zlog_warn("Interface %s does not have any link-local address", +			  ifp->name); +	} + +	/* Update running status of the interface. */ +	if (ri->enable_network || ri->enable_interface) { +		zlog_info("RIPng INTERFACE ON %s", ifp->name); + +		/* Add interface wake up thread. */ +		thread_add_timer(master, ripng_interface_wakeup, ifp, 1, +				 &ri->t_wakeup); + +		ripng_connect_set(ifp, 1); +	} else { +		if (ri->running) { +			/* Might as well clean up the route table as well +			 * ripng_if_down sets to 0 ri->running, and displays +			 *"turn off %s" +			 **/ +			ripng_if_down(ifp); + +			ripng_connect_set(ifp, 0); +		}  	} -    }  }  /* Set distribute list to all interfaces. */ -static void -ripng_enable_apply_all (void) +static void ripng_enable_apply_all(void)  { -  struct interface *ifp; -  struct listnode *node; +	struct interface *ifp; +	struct listnode *node; -  for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) -    ripng_enable_apply (ifp); +	for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) +		ripng_enable_apply(ifp);  }  /* Clear all network and neighbor configuration */ -void -ripng_clean_network () +void ripng_clean_network()  { -  unsigned int i; -  char *str; -  struct route_node *rn; - -  /* ripng_enable_network */ -  for (rn = route_top (ripng_enable_network); rn; rn = route_next (rn)) -    if (rn->info) { -      rn->info = NULL; -      route_unlock_node(rn); -    } - -  /* ripng_enable_if */ -  for (i = 0; i < vector_active (ripng_enable_if); i++) -    if ((str = vector_slot (ripng_enable_if, i)) != NULL) { -      free (str); -      vector_slot (ripng_enable_if, i) = NULL; -    } +	unsigned int i; +	char *str; +	struct route_node *rn; + +	/* ripng_enable_network */ +	for (rn = route_top(ripng_enable_network); rn; rn = route_next(rn)) +		if (rn->info) { +			rn->info = NULL; +			route_unlock_node(rn); +		} + +	/* ripng_enable_if */ +	for (i = 0; i < vector_active(ripng_enable_if); i++) +		if ((str = vector_slot(ripng_enable_if, i)) != NULL) { +			free(str); +			vector_slot(ripng_enable_if, i) = NULL; +		}  }  /* Vector to store passive-interface name. */  vector Vripng_passive_interface;  /* Utility function for looking up passive interface settings. */ -static int -ripng_passive_interface_lookup (const char *ifname) +static int ripng_passive_interface_lookup(const char *ifname)  { -  unsigned int i; -  char *str; - -  for (i = 0; i < vector_active (Vripng_passive_interface); i++) -    if ((str = vector_slot (Vripng_passive_interface, i)) != NULL) -      if (strcmp (str, ifname) == 0) -	return i; -  return -1; +	unsigned int i; +	char *str; + +	for (i = 0; i < vector_active(Vripng_passive_interface); i++) +		if ((str = vector_slot(Vripng_passive_interface, i)) != NULL) +			if (strcmp(str, ifname) == 0) +				return i; +	return -1;  } -void -ripng_passive_interface_apply (struct interface *ifp) +void ripng_passive_interface_apply(struct interface *ifp)  { -  int ret; -  struct ripng_interface *ri; +	int ret; +	struct ripng_interface *ri; -  ri = ifp->info; +	ri = ifp->info; -  ret = ripng_passive_interface_lookup (ifp->name); -  if (ret < 0) -    ri->passive = 0; -  else -    ri->passive = 1; +	ret = ripng_passive_interface_lookup(ifp->name); +	if (ret < 0) +		ri->passive = 0; +	else +		ri->passive = 1;  } -static void -ripng_passive_interface_apply_all (void) +static void ripng_passive_interface_apply_all(void)  { -  struct interface *ifp; -  struct listnode *node; +	struct interface *ifp; +	struct listnode *node; -  for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) -    ripng_passive_interface_apply (ifp); +	for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) +		ripng_passive_interface_apply(ifp);  }  /* Passive interface. */ -static int -ripng_passive_interface_set (struct vty *vty, const char *ifname) +static int ripng_passive_interface_set(struct vty *vty, const char *ifname)  { -  if (ripng_passive_interface_lookup (ifname) >= 0) -    return CMD_WARNING_CONFIG_FAILED; +	if (ripng_passive_interface_lookup(ifname) >= 0) +		return CMD_WARNING_CONFIG_FAILED; -  vector_set (Vripng_passive_interface, strdup (ifname)); +	vector_set(Vripng_passive_interface, strdup(ifname)); -  ripng_passive_interface_apply_all (); +	ripng_passive_interface_apply_all(); -  return CMD_SUCCESS; +	return CMD_SUCCESS;  } -static int -ripng_passive_interface_unset (struct vty *vty, const char *ifname) +static int ripng_passive_interface_unset(struct vty *vty, const char *ifname)  { -  int i; -  char *str; +	int i; +	char *str; -  i = ripng_passive_interface_lookup (ifname); -  if (i < 0) -    return CMD_WARNING_CONFIG_FAILED; +	i = ripng_passive_interface_lookup(ifname); +	if (i < 0) +		return CMD_WARNING_CONFIG_FAILED; -  str = vector_slot (Vripng_passive_interface, i); -  free (str); -  vector_unset (Vripng_passive_interface, i); +	str = vector_slot(Vripng_passive_interface, i); +	free(str); +	vector_unset(Vripng_passive_interface, i); -  ripng_passive_interface_apply_all (); +	ripng_passive_interface_apply_all(); -  return CMD_SUCCESS; +	return CMD_SUCCESS;  }  /* Free all configured RIP passive-interface settings. */ -void -ripng_passive_interface_clean (void) +void ripng_passive_interface_clean(void)  { -  unsigned int i; -  char *str; - -  for (i = 0; i < vector_active (Vripng_passive_interface); i++) -    if ((str = vector_slot (Vripng_passive_interface, i)) != NULL) -      { -	free (str); -	vector_slot (Vripng_passive_interface, i) = NULL; -      } -  ripng_passive_interface_apply_all (); +	unsigned int i; +	char *str; + +	for (i = 0; i < vector_active(Vripng_passive_interface); i++) +		if ((str = vector_slot(Vripng_passive_interface, i)) != NULL) { +			free(str); +			vector_slot(Vripng_passive_interface, i) = NULL; +		} +	ripng_passive_interface_apply_all();  }  /* Write RIPng enable network and interface to the vty. */ -int -ripng_network_write (struct vty *vty, int config_mode) +int ripng_network_write(struct vty *vty, int config_mode)  { -  unsigned int i; -  const char *ifname; -  struct route_node *node; -  char buf[BUFSIZ]; - -  /* Write enable network. */ -  for (node = route_top (ripng_enable_network); node; node = route_next (node)) -    if (node->info) -      { -	struct prefix *p = &node->p; -	vty_out (vty, "%s%s/%d\n",  -		 config_mode ? " network " : "    ", -		 inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), -		 p->prefixlen); - -      } -   -  /* Write enable interface. */ -  for (i = 0; i < vector_active (ripng_enable_if); i++) -    if ((ifname = vector_slot (ripng_enable_if, i)) != NULL) -      vty_out (vty, "%s%s\n", -	       config_mode ? " network " : "    ", -	       ifname); - -  /* Write passive interface. */ -  if (config_mode) -    for (i = 0; i < vector_active (Vripng_passive_interface); i++) -      if ((ifname = vector_slot (Vripng_passive_interface, i)) != NULL) -        vty_out (vty, " passive-interface %s\n", ifname); - -  return 0; +	unsigned int i; +	const char *ifname; +	struct route_node *node; +	char buf[BUFSIZ]; + +	/* Write enable network. */ +	for (node = route_top(ripng_enable_network); node; +	     node = route_next(node)) +		if (node->info) { +			struct prefix *p = &node->p; +			vty_out(vty, "%s%s/%d\n", +				config_mode ? " network " : "    ", +				inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ), +				p->prefixlen); +		} + +	/* Write enable interface. */ +	for (i = 0; i < vector_active(ripng_enable_if); i++) +		if ((ifname = vector_slot(ripng_enable_if, i)) != NULL) +			vty_out(vty, "%s%s\n", +				config_mode ? " network " : "    ", ifname); + +	/* Write passive interface. */ +	if (config_mode) +		for (i = 0; i < vector_active(Vripng_passive_interface); i++) +			if ((ifname = vector_slot(Vripng_passive_interface, i)) +			    != NULL) +				vty_out(vty, " passive-interface %s\n", ifname); + +	return 0;  }  /* RIPng enable on specified interface or matched network. */ @@ -946,26 +915,25 @@ DEFUN (ripng_network,         "RIPng enable on specified interface or network.\n"         "Interface or address\n")  { -  int idx_if_or_addr = 1; -  int ret; -  struct prefix p; - -  ret = str2prefix (argv[idx_if_or_addr]->arg, &p); - -  /* Given string is IPv6 network or interface name. */ -  if (ret) -    ret = ripng_enable_network_add (&p); -  else -    ret = ripng_enable_if_add (argv[idx_if_or_addr]->arg); - -  if (ret < 0) -    { -      vty_out (vty, "There is same network configuration %s\n", -                 argv[idx_if_or_addr]->arg); -      return CMD_WARNING_CONFIG_FAILED; -    } - -  return CMD_SUCCESS; +	int idx_if_or_addr = 1; +	int ret; +	struct prefix p; + +	ret = str2prefix(argv[idx_if_or_addr]->arg, &p); + +	/* Given string is IPv6 network or interface name. */ +	if (ret) +		ret = ripng_enable_network_add(&p); +	else +		ret = ripng_enable_if_add(argv[idx_if_or_addr]->arg); + +	if (ret < 0) { +		vty_out(vty, "There is same network configuration %s\n", +			argv[idx_if_or_addr]->arg); +		return CMD_WARNING_CONFIG_FAILED; +	} + +	return CMD_SUCCESS;  }  /* RIPng enable on specified interface or matched network. */ @@ -976,25 +944,25 @@ DEFUN (no_ripng_network,         "RIPng enable on specified interface or network.\n"         "Interface or address\n")  { -  int idx_if_or_addr = 2; -  int ret; -  struct prefix p; - -  ret = str2prefix (argv[idx_if_or_addr]->arg, &p); - -  /* Given string is interface name. */ -  if (ret) -    ret = ripng_enable_network_delete (&p); -  else -    ret = ripng_enable_if_delete (argv[idx_if_or_addr]->arg); - -  if (ret < 0) -    { -      vty_out (vty, "can't find network %s\n",argv[idx_if_or_addr]->arg); -      return CMD_WARNING_CONFIG_FAILED; -    } -   -  return CMD_SUCCESS; +	int idx_if_or_addr = 2; +	int ret; +	struct prefix p; + +	ret = str2prefix(argv[idx_if_or_addr]->arg, &p); + +	/* Given string is interface name. */ +	if (ret) +		ret = ripng_enable_network_delete(&p); +	else +		ret = ripng_enable_if_delete(argv[idx_if_or_addr]->arg); + +	if (ret < 0) { +		vty_out(vty, "can't find network %s\n", +			argv[idx_if_or_addr]->arg); +		return CMD_WARNING_CONFIG_FAILED; +	} + +	return CMD_SUCCESS;  }  DEFUN (ipv6_ripng_split_horizon, @@ -1004,13 +972,13 @@ DEFUN (ipv6_ripng_split_horizon,         "Routing Information Protocol\n"         "Perform split horizon\n")  { -  VTY_DECLVAR_CONTEXT(interface, ifp); -  struct ripng_interface *ri; +	VTY_DECLVAR_CONTEXT(interface, ifp); +	struct ripng_interface *ri; -  ri = ifp->info; +	ri = ifp->info; -  ri->split_horizon = RIPNG_SPLIT_HORIZON; -  return CMD_SUCCESS; +	ri->split_horizon = RIPNG_SPLIT_HORIZON; +	return CMD_SUCCESS;  }  DEFUN (ipv6_ripng_split_horizon_poisoned_reverse, @@ -1021,13 +989,13 @@ DEFUN (ipv6_ripng_split_horizon_poisoned_reverse,         "Perform split horizon\n"         "With poisoned-reverse\n")  { -  VTY_DECLVAR_CONTEXT(interface, ifp); -  struct ripng_interface *ri; +	VTY_DECLVAR_CONTEXT(interface, ifp); +	struct ripng_interface *ri; -  ri = ifp->info; +	ri = ifp->info; -  ri->split_horizon = RIPNG_SPLIT_HORIZON_POISONED_REVERSE; -  return CMD_SUCCESS; +	ri->split_horizon = RIPNG_SPLIT_HORIZON_POISONED_REVERSE; +	return CMD_SUCCESS;  }  DEFUN (no_ipv6_ripng_split_horizon, @@ -1039,13 +1007,13 @@ DEFUN (no_ipv6_ripng_split_horizon,         "Perform split horizon\n"         "With poisoned-reverse\n")  { -  VTY_DECLVAR_CONTEXT(interface, ifp); -  struct ripng_interface *ri; +	VTY_DECLVAR_CONTEXT(interface, ifp); +	struct ripng_interface *ri; -  ri = ifp->info; +	ri = ifp->info; -  ri->split_horizon = RIPNG_NO_SPLIT_HORIZON; -  return CMD_SUCCESS; +	ri->split_horizon = RIPNG_NO_SPLIT_HORIZON; +	return CMD_SUCCESS;  }  DEFUN (ripng_passive_interface, @@ -1054,8 +1022,8 @@ DEFUN (ripng_passive_interface,         "Suppress routing updates on an interface\n"         "Interface name\n")  { -  int idx_ifname = 1; -  return ripng_passive_interface_set (vty, argv[idx_ifname]->arg); +	int idx_ifname = 1; +	return ripng_passive_interface_set(vty, argv[idx_ifname]->arg);  }  DEFUN (no_ripng_passive_interface, @@ -1065,125 +1033,117 @@ DEFUN (no_ripng_passive_interface,         "Suppress routing updates on an interface\n"         "Interface name\n")  { -  int idx_ifname = 2; -  return ripng_passive_interface_unset (vty, argv[idx_ifname]->arg); +	int idx_ifname = 2; +	return ripng_passive_interface_unset(vty, argv[idx_ifname]->arg);  } -static struct ripng_interface * -ri_new (void) +static struct ripng_interface *ri_new(void)  { -  struct ripng_interface *ri; -  ri = XCALLOC (MTYPE_IF, sizeof (struct ripng_interface)); +	struct ripng_interface *ri; +	ri = XCALLOC(MTYPE_IF, sizeof(struct ripng_interface)); -  /* Set default split-horizon behavior.  If the interface is Frame -     Relay or SMDS is enabled, the default value for split-horizon is -     off.  But currently Zebra does detect Frame Relay or SMDS -     interface.  So all interface is set to split horizon.  */ -  ri->split_horizon_default = RIPNG_SPLIT_HORIZON; -  ri->split_horizon = ri->split_horizon_default; +	/* Set default split-horizon behavior.  If the interface is Frame +	   Relay or SMDS is enabled, the default value for split-horizon is +	   off.  But currently Zebra does detect Frame Relay or SMDS +	   interface.  So all interface is set to split horizon.  */ +	ri->split_horizon_default = RIPNG_SPLIT_HORIZON; +	ri->split_horizon = ri->split_horizon_default; -  return ri; +	return ri;  } -static int -ripng_if_new_hook (struct interface *ifp) +static int ripng_if_new_hook(struct interface *ifp)  { -  ifp->info = ri_new (); -  return 0; +	ifp->info = ri_new(); +	return 0;  }  /* Called when interface structure deleted. */ -static int -ripng_if_delete_hook (struct interface *ifp) +static int ripng_if_delete_hook(struct interface *ifp)  { -  XFREE (MTYPE_IF, ifp->info); -  ifp->info = NULL; -  return 0; +	XFREE(MTYPE_IF, ifp->info); +	ifp->info = NULL; +	return 0;  }  /* Configuration write function for ripngd. */ -static int -interface_config_write (struct vty *vty) +static int interface_config_write(struct vty *vty)  { -  struct listnode *node; -  struct interface *ifp; -  struct ripng_interface *ri; -  int write = 0; - -  for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) -    { -      ri = ifp->info; - -      /* Do not display the interface if there is no -       * configuration about it. -       **/ -      if ((!ifp->desc) && -          (ri->split_horizon == ri->split_horizon_default)) -        continue; - -      vty_out (vty, "interface %s\n",ifp->name); -      if (ifp->desc) -	vty_out (vty, " description %s\n",ifp->desc); - -      /* Split horizon. */ -      if (ri->split_horizon != ri->split_horizon_default) -	{ -          switch (ri->split_horizon) { -          case RIPNG_SPLIT_HORIZON: -            vty_out (vty, " ipv6 ripng split-horizon\n"); -            break; -          case RIPNG_SPLIT_HORIZON_POISONED_REVERSE: -            vty_out (vty," ipv6 ripng split-horizon poisoned-reverse\n"); -            break; -          case RIPNG_NO_SPLIT_HORIZON: -          default: -            vty_out (vty, " no ipv6 ripng split-horizon\n"); -            break; -          } +	struct listnode *node; +	struct interface *ifp; +	struct ripng_interface *ri; +	int write = 0; + +	for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) { +		ri = ifp->info; + +		/* Do not display the interface if there is no +		 * configuration about it. +		 **/ +		if ((!ifp->desc) +		    && (ri->split_horizon == ri->split_horizon_default)) +			continue; + +		vty_out(vty, "interface %s\n", ifp->name); +		if (ifp->desc) +			vty_out(vty, " description %s\n", ifp->desc); + +		/* Split horizon. */ +		if (ri->split_horizon != ri->split_horizon_default) { +			switch (ri->split_horizon) { +			case RIPNG_SPLIT_HORIZON: +				vty_out(vty, " ipv6 ripng split-horizon\n"); +				break; +			case RIPNG_SPLIT_HORIZON_POISONED_REVERSE: +				vty_out(vty, +					" ipv6 ripng split-horizon poisoned-reverse\n"); +				break; +			case RIPNG_NO_SPLIT_HORIZON: +			default: +				vty_out(vty, " no ipv6 ripng split-horizon\n"); +				break; +			} +		} + +		vty_out(vty, "!\n"); + +		write++;  	} - -      vty_out (vty, "!\n"); - -      write++; -    } -  return write; +	return write;  }  /* ripngd's interface node. */ -static struct cmd_node interface_node = -{ -  INTERFACE_NODE, -  "%s(config-if)# ", -  1 /* VTYSH */ +static struct cmd_node interface_node = { +	INTERFACE_NODE, "%s(config-if)# ", 1 /* VTYSH */  };  /* Initialization of interface. */ -void -ripng_if_init () +void ripng_if_init()  { -  /* Interface initialize. */ -  if_add_hook (IF_NEW_HOOK, ripng_if_new_hook); -  if_add_hook (IF_DELETE_HOOK, ripng_if_delete_hook); +	/* Interface initialize. */ +	if_add_hook(IF_NEW_HOOK, ripng_if_new_hook); +	if_add_hook(IF_DELETE_HOOK, ripng_if_delete_hook); -  /* RIPng enable network init. */ -  ripng_enable_network = route_table_init (); +	/* RIPng enable network init. */ +	ripng_enable_network = route_table_init(); -  /* RIPng enable interface init. */ -  ripng_enable_if = vector_init (1); +	/* RIPng enable interface init. */ +	ripng_enable_if = vector_init(1); -  /* RIPng passive interface. */ -  Vripng_passive_interface = vector_init (1); +	/* RIPng passive interface. */ +	Vripng_passive_interface = vector_init(1); -  /* Install interface node. */ -  install_node (&interface_node, interface_config_write); -  if_cmd_init (); +	/* Install interface node. */ +	install_node(&interface_node, interface_config_write); +	if_cmd_init(); -  install_element (RIPNG_NODE, &ripng_network_cmd); -  install_element (RIPNG_NODE, &no_ripng_network_cmd); -  install_element (RIPNG_NODE, &ripng_passive_interface_cmd); -  install_element (RIPNG_NODE, &no_ripng_passive_interface_cmd); +	install_element(RIPNG_NODE, &ripng_network_cmd); +	install_element(RIPNG_NODE, &no_ripng_network_cmd); +	install_element(RIPNG_NODE, &ripng_passive_interface_cmd); +	install_element(RIPNG_NODE, &no_ripng_passive_interface_cmd); -  install_element (INTERFACE_NODE, &ipv6_ripng_split_horizon_cmd); -  install_element (INTERFACE_NODE, &ipv6_ripng_split_horizon_poisoned_reverse_cmd); -  install_element (INTERFACE_NODE, &no_ipv6_ripng_split_horizon_cmd); +	install_element(INTERFACE_NODE, &ipv6_ripng_split_horizon_cmd); +	install_element(INTERFACE_NODE, +			&ipv6_ripng_split_horizon_poisoned_reverse_cmd); +	install_element(INTERFACE_NODE, &no_ipv6_ripng_split_horizon_cmd);  } diff --git a/ripngd/ripng_main.c b/ripngd/ripng_main.c index 9d700305ed..0cb54d4335 100644 --- a/ripngd/ripng_main.c +++ b/ripngd/ripng_main.c @@ -40,34 +40,24 @@  #include "ripngd/ripngd.h"  /* RIPngd options. */ -struct option longopts[] =  -{ -  { "retain",      no_argument,       NULL, 'r'}, -  { 0 } -}; +struct option longopts[] = {{"retain", no_argument, NULL, 'r'}, {0}};  /* ripngd privileges */ -zebra_capabilities_t _caps_p [] =  -{ -  ZCAP_NET_RAW, -  ZCAP_BIND -}; +zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND}; -struct zebra_privs_t ripngd_privs = -{ +struct zebra_privs_t ripngd_privs = {  #if defined(FRR_USER) -  .user = FRR_USER, +	.user = FRR_USER,  #endif  #if defined FRR_GROUP -  .group = FRR_GROUP, +	.group = FRR_GROUP,  #endif  #ifdef VTY_GROUP -  .vty_group = VTY_GROUP, +	.vty_group = VTY_GROUP,  #endif -  .caps_p = _caps_p, -  .cap_num_p = 2, -  .cap_num_i = 0 -}; +	.caps_p = _caps_p, +	.cap_num_p = 2, +	.cap_num_i = 0};  /* RIPngd program name */ @@ -81,113 +71,105 @@ struct thread_master *master;  static struct frr_daemon_info ripngd_di;  /* SIGHUP handler. */ -static void  -sighup (void) +static void sighup(void)  { -  zlog_info ("SIGHUP received"); -  ripng_clean (); -  ripng_reset (); +	zlog_info("SIGHUP received"); +	ripng_clean(); +	ripng_reset(); -  /* Reload config file. */ -  vty_read_config (ripngd_di.config_file, config_default); +	/* Reload config file. */ +	vty_read_config(ripngd_di.config_file, config_default); -  /* Try to return to normal operation. */ +	/* Try to return to normal operation. */  }  /* SIGINT handler. */ -static void -sigint (void) +static void sigint(void)  { -  zlog_notice ("Terminating on signal"); +	zlog_notice("Terminating on signal"); -  if (! retain_mode) -    ripng_clean (); +	if (!retain_mode) +		ripng_clean(); -  ripng_zebra_stop (); -  exit (0); +	ripng_zebra_stop(); +	exit(0);  }  /* SIGUSR1 handler. */ -static void -sigusr1 (void) +static void sigusr1(void)  { -  zlog_rotate(); +	zlog_rotate();  } -struct quagga_signal_t ripng_signals[] = -{ -  {  -    .signal = SIGHUP,  -    .handler = &sighup, -  }, -  { -    .signal = SIGUSR1, -    .handler = &sigusr1, -  }, -  { -    .signal = SIGINT, -    .handler = &sigint, -  }, -  { -    .signal = SIGTERM, -    .handler = &sigint, -  }, +struct quagga_signal_t ripng_signals[] = { +	{ +		.signal = SIGHUP, +		.handler = &sighup, +	}, +	{ +		.signal = SIGUSR1, +		.handler = &sigusr1, +	}, +	{ +		.signal = SIGINT, +		.handler = &sigint, +	}, +	{ +		.signal = SIGTERM, +		.handler = &sigint, +	},  }; -FRR_DAEMON_INFO(ripngd, RIPNG, -	.vty_port = RIPNG_VTY_PORT, +FRR_DAEMON_INFO(ripngd, RIPNG, .vty_port = RIPNG_VTY_PORT, -	.proghelp = "Implementation of the RIPng routing protocol.", +		.proghelp = "Implementation of the RIPng routing protocol.", -	.signals = ripng_signals, -	.n_signals = array_size(ripng_signals), +		.signals = ripng_signals, +		.n_signals = array_size(ripng_signals), -	.privs = &ripngd_privs, -) +		.privs = &ripngd_privs, )  /* RIPngd main routine. */ -int -main (int argc, char **argv) +int main(int argc, char **argv)  { -  frr_preinit (&ripngd_di, argc, argv); -  frr_opt_add ("r", longopts, -	"  -r, --retain       When program terminates, retain added route by ripd.\n"); - -  while (1)  -    { -      int opt; - -      opt = frr_getopt (argc, argv, NULL); -     -      if (opt == EOF) -	break; - -      switch (opt)  -	{ -	case 0: -	  break; -	case 'r': -	  retain_mode = 1; -	  break; -	default: -	  frr_help_exit (1); -	  break; +	frr_preinit(&ripngd_di, argc, argv); +	frr_opt_add( +		"r", longopts, +		"  -r, --retain       When program terminates, retain added route by ripd.\n"); + +	while (1) { +		int opt; + +		opt = frr_getopt(argc, argv, NULL); + +		if (opt == EOF) +			break; + +		switch (opt) { +		case 0: +			break; +		case 'r': +			retain_mode = 1; +			break; +		default: +			frr_help_exit(1); +			break; +		}  	} -    } -  master = frr_init (); +	master = frr_init(); -  /* Library inits. */ -  vrf_init (NULL, NULL, NULL, NULL); +	/* Library inits. */ +	vrf_init(NULL, NULL, NULL, NULL); -  /* RIPngd inits. */ -  ripng_init (); -  zebra_init(master); -  ripng_peer_init (); +	/* RIPngd inits. */ +	ripng_init(); +	zebra_init(master); +	ripng_peer_init(); -  frr_config_fork (); -  frr_run (master); +	frr_config_fork(); +	frr_run(master); -  /* Not reached. */ -  return 0; +	/* Not reached. */ +	return 0;  } diff --git a/ripngd/ripng_memory.c b/ripngd/ripng_memory.c index 60fb1751d7..0cb24052e6 100644 --- a/ripngd/ripng_memory.c +++ b/ripngd/ripng_memory.c @@ -26,9 +26,9 @@  #include "ripng_memory.h"  DEFINE_MGROUP(RIPNGD, "ripngd") -DEFINE_MTYPE(RIPNGD, RIPNG,             "RIPng structure") -DEFINE_MTYPE(RIPNGD, RIPNG_ROUTE,       "RIPng route info") -DEFINE_MTYPE(RIPNGD, RIPNG_AGGREGATE,   "RIPng aggregate") -DEFINE_MTYPE(RIPNGD, RIPNG_PEER,        "RIPng peer") +DEFINE_MTYPE(RIPNGD, RIPNG, "RIPng structure") +DEFINE_MTYPE(RIPNGD, RIPNG_ROUTE, "RIPng route info") +DEFINE_MTYPE(RIPNGD, RIPNG_AGGREGATE, "RIPng aggregate") +DEFINE_MTYPE(RIPNGD, RIPNG_PEER, "RIPng peer")  DEFINE_MTYPE(RIPNGD, RIPNG_OFFSET_LIST, "RIPng offset lst") -DEFINE_MTYPE(RIPNGD, RIPNG_RTE_DATA,    "RIPng rte data") +DEFINE_MTYPE(RIPNGD, RIPNG_RTE_DATA, "RIPng rte data") diff --git a/ripngd/ripng_nexthop.c b/ripngd/ripng_nexthop.c index 0af636efcb..75b3c9dfec 100644 --- a/ripngd/ripng_nexthop.c +++ b/ripngd/ripng_nexthop.c @@ -44,41 +44,41 @@  #define min(a, b) ((a) < (b) ? (a) : (b))  struct ripng_rte_data { -  struct prefix_ipv6 *p; -  struct ripng_info *rinfo; -  struct ripng_aggregate *aggregate; +	struct prefix_ipv6 *p; +	struct ripng_info *rinfo; +	struct ripng_aggregate *aggregate;  };  void _ripng_rte_del(struct ripng_rte_data *A);  int _ripng_rte_cmp(struct ripng_rte_data *A, struct ripng_rte_data *B); -#define METRIC_OUT(a) \ -    ((a)->rinfo ?  (a)->rinfo->metric_out : (a)->aggregate->metric_out) -#define NEXTHOP_OUT_PTR(a) \ -    ((a)->rinfo ?  &((a)->rinfo->nexthop_out) : &((a)->aggregate->nexthop_out)) -#define TAG_OUT(a) \ -    ((a)->rinfo ?  (a)->rinfo->tag_out : (a)->aggregate->tag_out) +#define METRIC_OUT(a)                                                          \ +	((a)->rinfo ? (a)->rinfo->metric_out : (a)->aggregate->metric_out) +#define NEXTHOP_OUT_PTR(a)                                                     \ +	((a)->rinfo ? &((a)->rinfo->nexthop_out)                               \ +		    : &((a)->aggregate->nexthop_out)) +#define TAG_OUT(a) ((a)->rinfo ? (a)->rinfo->tag_out : (a)->aggregate->tag_out) -struct list * -ripng_rte_new(void) { -  struct list *rte; +struct list *ripng_rte_new(void) +{ +	struct list *rte; -  rte = list_new(); -  rte->cmp = (int (*)(void *, void *)) _ripng_rte_cmp; -  rte->del = (void (*)(void *)) _ripng_rte_del; +	rte = list_new(); +	rte->cmp = (int (*)(void *, void *))_ripng_rte_cmp; +	rte->del = (void (*)(void *))_ripng_rte_del; -  return rte; +	return rte;  } -void -ripng_rte_free(struct list *ripng_rte_list) { -  list_delete(ripng_rte_list); +void ripng_rte_free(struct list *ripng_rte_list) +{ +	list_delete(ripng_rte_list);  }  /* Delete RTE */ -void -_ripng_rte_del(struct ripng_rte_data *A) { -  XFREE(MTYPE_RIPNG_RTE_DATA, A); +void _ripng_rte_del(struct ripng_rte_data *A) +{ +	XFREE(MTYPE_RIPNG_RTE_DATA, A);  }  /* Compare RTE: @@ -86,128 +86,138 @@ _ripng_rte_del(struct ripng_rte_data *A) {   *         0  if A = B   *         -  if A < B   */ -int -_ripng_rte_cmp(struct ripng_rte_data *A, struct ripng_rte_data *B) { -  return addr6_cmp(NEXTHOP_OUT_PTR(A), NEXTHOP_OUT_PTR(B)); +int _ripng_rte_cmp(struct ripng_rte_data *A, struct ripng_rte_data *B) +{ +	return addr6_cmp(NEXTHOP_OUT_PTR(A), NEXTHOP_OUT_PTR(B));  }  /* Add routing table entry */ -void -ripng_rte_add(struct list *ripng_rte_list, struct prefix_ipv6 *p, -              struct ripng_info *rinfo, struct ripng_aggregate *aggregate) { +void ripng_rte_add(struct list *ripng_rte_list, struct prefix_ipv6 *p, +		   struct ripng_info *rinfo, struct ripng_aggregate *aggregate) +{ -  struct ripng_rte_data *data; +	struct ripng_rte_data *data; -  /* At least one should not be null */ -  assert(!rinfo || !aggregate); +	/* At least one should not be null */ +	assert(!rinfo || !aggregate); -  data = XMALLOC(MTYPE_RIPNG_RTE_DATA, sizeof(*data)); -  data->p     = p; -  data->rinfo = rinfo; -  data->aggregate = aggregate; +	data = XMALLOC(MTYPE_RIPNG_RTE_DATA, sizeof(*data)); +	data->p = p; +	data->rinfo = rinfo; +	data->aggregate = aggregate; -  listnode_add_sort(ripng_rte_list, data); -}  +	listnode_add_sort(ripng_rte_list, data); +}  /* Send the RTE with the nexthop support   */ -void -ripng_rte_send(struct list *ripng_rte_list, struct interface *ifp, -               struct sockaddr_in6 *to) { - -  struct ripng_rte_data *data; -  struct listnode *node, *nnode; - -  struct in6_addr last_nexthop; -  struct in6_addr myself_nexthop; - -  struct stream *s; -  int num; -  int mtu; -  int rtemax; -  int ret; - -  /* Most of the time, there is no nexthop */ -  memset(&last_nexthop, 0, sizeof(last_nexthop)); - -  /* Use myself_nexthop if the nexthop is not a link-local address, because -   * we remain a right path without beeing the optimal one. -   */ -  memset(&myself_nexthop, 0, sizeof(myself_nexthop)); - -  /* Output stream get from ripng structre.  XXX this should be -     interface structure. */ -  s = ripng->obuf; - -  /* Reset stream and RTE counter. */ -  stream_reset (s); -  num = 0; - -  mtu = ifp->mtu6; -  if (mtu < 0) -    mtu = IFMINMTU; - -  rtemax = (min (mtu, RIPNG_MAX_PACKET_SIZE) - -	    IPV6_HDRLEN -  -	    sizeof (struct udphdr) - -	    sizeof (struct ripng_packet) + -	    sizeof (struct rte)) / sizeof (struct rte); - -  for (ALL_LIST_ELEMENTS (ripng_rte_list, node, nnode, data)) { -    /* (2.1) Next hop support */ -    if (!IPV6_ADDR_SAME(&last_nexthop, NEXTHOP_OUT_PTR(data))) { - -      /* A nexthop entry should be at least followed by 1 RTE */ -      if (num == (rtemax-1)) { -	ret = ripng_send_packet ((caddr_t) STREAM_DATA (s), stream_get_endp (s), -				 to, ifp); - -        if (ret >= 0 && IS_RIPNG_DEBUG_SEND) -          ripng_packet_dump((struct ripng_packet *)STREAM_DATA (s), -			    stream_get_endp(s), "SEND"); -        num = 0; -        stream_reset (s); -      } - -      /* Add the nexthop (2.1) */ - -      /* If the received next hop address is not a link-local address, -       * it should be treated as 0:0:0:0:0:0:0:0. -       */ -      if (!IN6_IS_ADDR_LINKLOCAL(NEXTHOP_OUT_PTR(data))) -        last_nexthop = myself_nexthop; -      else -	last_nexthop = *NEXTHOP_OUT_PTR(data); - -      num = ripng_write_rte(num, s, NULL, &last_nexthop, 0, RIPNG_METRIC_NEXTHOP); -    } else { -      /* Rewrite the nexthop for each new packet */ -      if ((num == 0) && !IPV6_ADDR_SAME(&last_nexthop, &myself_nexthop)) -        num = ripng_write_rte(num, s, NULL, &last_nexthop, 0, RIPNG_METRIC_NEXTHOP); -    } -    num = ripng_write_rte(num, s, data->p, NULL, -			  TAG_OUT(data), METRIC_OUT(data)); - -    if (num == rtemax) { -      ret = ripng_send_packet ((caddr_t) STREAM_DATA (s), stream_get_endp (s), -			       to, ifp); - -      if (ret >= 0 && IS_RIPNG_DEBUG_SEND) -        ripng_packet_dump((struct ripng_packet *)STREAM_DATA (s), -			  stream_get_endp(s), "SEND"); -      num = 0; -      stream_reset (s); -    } -  } - -  /* If unwritten RTE exist, flush it. */ -  if (num != 0) { -    ret = ripng_send_packet ((caddr_t) STREAM_DATA (s), stream_get_endp (s), -			     to, ifp); - -    if (ret >= 0 && IS_RIPNG_DEBUG_SEND) -      ripng_packet_dump ((struct ripng_packet *)STREAM_DATA (s), -			 stream_get_endp (s), "SEND"); -    stream_reset (s); -  } +void ripng_rte_send(struct list *ripng_rte_list, struct interface *ifp, +		    struct sockaddr_in6 *to) +{ + +	struct ripng_rte_data *data; +	struct listnode *node, *nnode; + +	struct in6_addr last_nexthop; +	struct in6_addr myself_nexthop; + +	struct stream *s; +	int num; +	int mtu; +	int rtemax; +	int ret; + +	/* Most of the time, there is no nexthop */ +	memset(&last_nexthop, 0, sizeof(last_nexthop)); + +	/* Use myself_nexthop if the nexthop is not a link-local address, +	 * because +	 * we remain a right path without beeing the optimal one. +	 */ +	memset(&myself_nexthop, 0, sizeof(myself_nexthop)); + +	/* Output stream get from ripng structre.  XXX this should be +	   interface structure. */ +	s = ripng->obuf; + +	/* Reset stream and RTE counter. */ +	stream_reset(s); +	num = 0; + +	mtu = ifp->mtu6; +	if (mtu < 0) +		mtu = IFMINMTU; + +	rtemax = (min(mtu, RIPNG_MAX_PACKET_SIZE) - IPV6_HDRLEN +		  - sizeof(struct udphdr) - sizeof(struct ripng_packet) +		  + sizeof(struct rte)) +		 / sizeof(struct rte); + +	for (ALL_LIST_ELEMENTS(ripng_rte_list, node, nnode, data)) { +		/* (2.1) Next hop support */ +		if (!IPV6_ADDR_SAME(&last_nexthop, NEXTHOP_OUT_PTR(data))) { + +			/* A nexthop entry should be at least followed by 1 RTE +			 */ +			if (num == (rtemax - 1)) { +				ret = ripng_send_packet((caddr_t)STREAM_DATA(s), +							stream_get_endp(s), to, +							ifp); + +				if (ret >= 0 && IS_RIPNG_DEBUG_SEND) +					ripng_packet_dump( +						(struct ripng_packet *) +							STREAM_DATA(s), +						stream_get_endp(s), "SEND"); +				num = 0; +				stream_reset(s); +			} + +			/* Add the nexthop (2.1) */ + +			/* If the received next hop address is not a link-local +			 * address, +			 * it should be treated as 0:0:0:0:0:0:0:0. +			 */ +			if (!IN6_IS_ADDR_LINKLOCAL(NEXTHOP_OUT_PTR(data))) +				last_nexthop = myself_nexthop; +			else +				last_nexthop = *NEXTHOP_OUT_PTR(data); + +			num = ripng_write_rte(num, s, NULL, &last_nexthop, 0, +					      RIPNG_METRIC_NEXTHOP); +		} else { +			/* Rewrite the nexthop for each new packet */ +			if ((num == 0) +			    && !IPV6_ADDR_SAME(&last_nexthop, &myself_nexthop)) +				num = ripng_write_rte(num, s, NULL, +						      &last_nexthop, 0, +						      RIPNG_METRIC_NEXTHOP); +		} +		num = ripng_write_rte(num, s, data->p, NULL, TAG_OUT(data), +				      METRIC_OUT(data)); + +		if (num == rtemax) { +			ret = ripng_send_packet((caddr_t)STREAM_DATA(s), +						stream_get_endp(s), to, ifp); + +			if (ret >= 0 && IS_RIPNG_DEBUG_SEND) +				ripng_packet_dump( +					(struct ripng_packet *)STREAM_DATA(s), +					stream_get_endp(s), "SEND"); +			num = 0; +			stream_reset(s); +		} +	} + +	/* If unwritten RTE exist, flush it. */ +	if (num != 0) { +		ret = ripng_send_packet((caddr_t)STREAM_DATA(s), +					stream_get_endp(s), to, ifp); + +		if (ret >= 0 && IS_RIPNG_DEBUG_SEND) +			ripng_packet_dump((struct ripng_packet *)STREAM_DATA(s), +					  stream_get_endp(s), "SEND"); +		stream_reset(s); +	}  } diff --git a/ripngd/ripng_nexthop.h b/ripngd/ripng_nexthop.h index 76873f80eb..92ab7e0cdb 100644 --- a/ripngd/ripng_nexthop.h +++ b/ripngd/ripng_nexthop.h @@ -26,38 +26,39 @@  #include "ripngd/ripng_route.h"  #include "ripngd/ripngd.h" -extern struct list * ripng_rte_new(void); +extern struct list *ripng_rte_new(void);  extern void ripng_rte_free(struct list *ripng_rte_list);  extern void ripng_rte_add(struct list *ripng_rte_list, struct prefix_ipv6 *p, -                          struct ripng_info *rinfo, -                          struct ripng_aggregate *aggregate); +			  struct ripng_info *rinfo, +			  struct ripng_aggregate *aggregate);  extern void ripng_rte_send(struct list *ripng_rte_list, struct interface *ifp, -                           struct sockaddr_in6 *to); +			   struct sockaddr_in6 *to);  /***   * 1 if A > B   * 0 if A = B   * -1 if A < B   **/ -static inline int -addr6_cmp(struct in6_addr *A, struct in6_addr *B) +static inline int addr6_cmp(struct in6_addr *A, struct in6_addr *B)  {  #define a(i) A->s6_addr32[i]  #define b(i) B->s6_addr32[i] -  if (a(3) > b(3)) -    return 1; -  else if ((a(3) == b(3)) && (a(2) > b(2))) -    return 1; -  else if ((a(3) == b(3)) && (a(2) == b(2)) && (a(1) > b(1))) -    return 1; -  else if ((a(3) == b(3)) && (a(2) == b(2)) && (a(1) == b(1)) && (a(0) > b(0))) -    return 1; +	if (a(3) > b(3)) +		return 1; +	else if ((a(3) == b(3)) && (a(2) > b(2))) +		return 1; +	else if ((a(3) == b(3)) && (a(2) == b(2)) && (a(1) > b(1))) +		return 1; +	else if ((a(3) == b(3)) && (a(2) == b(2)) && (a(1) == b(1)) +		 && (a(0) > b(0))) +		return 1; -  if ((a(3) == b(3)) && (a(2) == b(2)) && (a(1) == b(1)) && (a(0) == b(0))) -    return 0; +	if ((a(3) == b(3)) && (a(2) == b(2)) && (a(1) == b(1)) +	    && (a(0) == b(0))) +		return 0; -  return -1; +	return -1;  }  #endif /* _ZEBRA_RIPNG_RIPNG_NEXTHOP_H */ diff --git a/ripngd/ripng_offset.c b/ripngd/ripng_offset.c index 81e892d7d0..efbdc1ffe8 100644 --- a/ripngd/ripng_offset.c +++ b/ripngd/ripng_offset.c @@ -18,9 +18,9 @@   * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA   */ - /* RIPng support by Vincent Jardin <vincent.jardin@6wind.com> -  * Copyright (C) 2002 6WIND -  */ +/* RIPng support by Vincent Jardin <vincent.jardin@6wind.com> + * Copyright (C) 2002 6WIND + */  #include <zebra.h> @@ -37,169 +37,153 @@  #define RIPNG_OFFSET_LIST_OUT 1  #define RIPNG_OFFSET_LIST_MAX 2 -struct ripng_offset_list -{ -  char *ifname; - -  struct  -  { -    char *alist_name; -    /* struct access_list *alist; */ -    int metric; -  } direct[RIPNG_OFFSET_LIST_MAX]; +struct ripng_offset_list { +	char *ifname; + +	struct { +		char *alist_name; +		/* struct access_list *alist; */ +		int metric; +	} direct[RIPNG_OFFSET_LIST_MAX];  };  static struct list *ripng_offset_list_master; -static int -strcmp_safe (const char *s1, const char *s2) +static int strcmp_safe(const char *s1, const char *s2)  { -  if (s1 == NULL && s2 == NULL) -    return 0; -  if (s1 == NULL) -    return -1; -  if (s2 == NULL) -    return 1; -  return strcmp (s1, s2); +	if (s1 == NULL && s2 == NULL) +		return 0; +	if (s1 == NULL) +		return -1; +	if (s2 == NULL) +		return 1; +	return strcmp(s1, s2);  } -static struct ripng_offset_list * -ripng_offset_list_new (void) +static struct ripng_offset_list *ripng_offset_list_new(void)  { -  struct ripng_offset_list *new; +	struct ripng_offset_list *new; -  new = XCALLOC (MTYPE_RIPNG_OFFSET_LIST, sizeof (struct ripng_offset_list)); -  return new; +	new = XCALLOC(MTYPE_RIPNG_OFFSET_LIST, +		      sizeof(struct ripng_offset_list)); +	return new;  } -static void -ripng_offset_list_free (struct ripng_offset_list *offset) +static void ripng_offset_list_free(struct ripng_offset_list *offset)  { -  XFREE (MTYPE_RIPNG_OFFSET_LIST, offset); +	XFREE(MTYPE_RIPNG_OFFSET_LIST, offset);  } -static struct ripng_offset_list * -ripng_offset_list_lookup (const char *ifname) +static struct ripng_offset_list *ripng_offset_list_lookup(const char *ifname)  { -  struct ripng_offset_list *offset; -  struct listnode *node, *nnode; +	struct ripng_offset_list *offset; +	struct listnode *node, *nnode; -  for (ALL_LIST_ELEMENTS (ripng_offset_list_master, node, nnode, offset)) -    { -      if (strcmp_safe (offset->ifname, ifname) == 0) -	return offset; -    } -  return NULL; +	for (ALL_LIST_ELEMENTS(ripng_offset_list_master, node, nnode, offset)) { +		if (strcmp_safe(offset->ifname, ifname) == 0) +			return offset; +	} +	return NULL;  } -static struct ripng_offset_list * -ripng_offset_list_get (const char *ifname) +static struct ripng_offset_list *ripng_offset_list_get(const char *ifname)  { -  struct ripng_offset_list *offset; -   -  offset = ripng_offset_list_lookup (ifname); -  if (offset) -    return offset; - -  offset = ripng_offset_list_new (); -  if (ifname) -    offset->ifname = strdup (ifname); -  listnode_add_sort (ripng_offset_list_master, offset); - -  return offset; +	struct ripng_offset_list *offset; + +	offset = ripng_offset_list_lookup(ifname); +	if (offset) +		return offset; + +	offset = ripng_offset_list_new(); +	if (ifname) +		offset->ifname = strdup(ifname); +	listnode_add_sort(ripng_offset_list_master, offset); + +	return offset;  } -static int -ripng_offset_list_set (struct vty *vty, const char *alist, -		       const char *direct_str, const char *metric_str, -		       const char *ifname) +static int ripng_offset_list_set(struct vty *vty, const char *alist, +				 const char *direct_str, const char *metric_str, +				 const char *ifname)  { -  int direct; -  int metric; -  struct ripng_offset_list *offset; - -  /* Check direction. */ -  if (strncmp (direct_str, "i", 1) == 0) -    direct = RIPNG_OFFSET_LIST_IN; -  else if (strncmp (direct_str, "o", 1) == 0) -    direct = RIPNG_OFFSET_LIST_OUT; -  else -    { -      vty_out (vty, "Invalid direction: %s\n", direct_str); -      return CMD_WARNING_CONFIG_FAILED; -    } - -  /* Check metric. */ -  metric = atoi (metric_str); -  if (metric < 0 || metric > 16) -    { -      vty_out (vty, "Invalid metric: %s\n", metric_str); -      return CMD_WARNING_CONFIG_FAILED; -    } - -  /* Get offset-list structure with interface name. */ -  offset = ripng_offset_list_get (ifname); - -  if (offset->direct[direct].alist_name) -    free (offset->direct[direct].alist_name); -  offset->direct[direct].alist_name = strdup (alist); -  offset->direct[direct].metric = metric; - -  return CMD_SUCCESS; +	int direct; +	int metric; +	struct ripng_offset_list *offset; + +	/* Check direction. */ +	if (strncmp(direct_str, "i", 1) == 0) +		direct = RIPNG_OFFSET_LIST_IN; +	else if (strncmp(direct_str, "o", 1) == 0) +		direct = RIPNG_OFFSET_LIST_OUT; +	else { +		vty_out(vty, "Invalid direction: %s\n", direct_str); +		return CMD_WARNING_CONFIG_FAILED; +	} + +	/* Check metric. */ +	metric = atoi(metric_str); +	if (metric < 0 || metric > 16) { +		vty_out(vty, "Invalid metric: %s\n", metric_str); +		return CMD_WARNING_CONFIG_FAILED; +	} + +	/* Get offset-list structure with interface name. */ +	offset = ripng_offset_list_get(ifname); + +	if (offset->direct[direct].alist_name) +		free(offset->direct[direct].alist_name); +	offset->direct[direct].alist_name = strdup(alist); +	offset->direct[direct].metric = metric; + +	return CMD_SUCCESS;  } -static int -ripng_offset_list_unset (struct vty *vty, const char *alist, -			 const char *direct_str, const char *metric_str, -			 const char *ifname) +static int ripng_offset_list_unset(struct vty *vty, const char *alist, +				   const char *direct_str, +				   const char *metric_str, const char *ifname)  { -  int direct; -  int metric; -  struct ripng_offset_list *offset; - -  /* Check direction. */ -  if (strncmp (direct_str, "i", 1) == 0) -    direct = RIPNG_OFFSET_LIST_IN; -  else if (strncmp (direct_str, "o", 1) == 0) -    direct = RIPNG_OFFSET_LIST_OUT; -  else -    { -      vty_out (vty, "Invalid direction: %s\n", direct_str); -      return CMD_WARNING_CONFIG_FAILED; -    } - -  /* Check metric. */ -  metric = atoi (metric_str); -  if (metric < 0 || metric > 16) -    { -      vty_out (vty, "Invalid metric: %s\n", metric_str); -      return CMD_WARNING_CONFIG_FAILED; -    } - -  /* Get offset-list structure with interface name. */ -  offset = ripng_offset_list_lookup (ifname); - -  if (offset) -    { -      if (offset->direct[direct].alist_name) -	free (offset->direct[direct].alist_name); -      offset->direct[direct].alist_name = NULL; - -      if (offset->direct[RIPNG_OFFSET_LIST_IN].alist_name == NULL && -	  offset->direct[RIPNG_OFFSET_LIST_OUT].alist_name == NULL) -	{ -	  listnode_delete (ripng_offset_list_master, offset); -	  if (offset->ifname) -	    free (offset->ifname); -	  ripng_offset_list_free (offset); +	int direct; +	int metric; +	struct ripng_offset_list *offset; + +	/* Check direction. */ +	if (strncmp(direct_str, "i", 1) == 0) +		direct = RIPNG_OFFSET_LIST_IN; +	else if (strncmp(direct_str, "o", 1) == 0) +		direct = RIPNG_OFFSET_LIST_OUT; +	else { +		vty_out(vty, "Invalid direction: %s\n", direct_str); +		return CMD_WARNING_CONFIG_FAILED; +	} + +	/* Check metric. */ +	metric = atoi(metric_str); +	if (metric < 0 || metric > 16) { +		vty_out(vty, "Invalid metric: %s\n", metric_str); +		return CMD_WARNING_CONFIG_FAILED; +	} + +	/* Get offset-list structure with interface name. */ +	offset = ripng_offset_list_lookup(ifname); + +	if (offset) { +		if (offset->direct[direct].alist_name) +			free(offset->direct[direct].alist_name); +		offset->direct[direct].alist_name = NULL; + +		if (offset->direct[RIPNG_OFFSET_LIST_IN].alist_name == NULL +		    && offset->direct[RIPNG_OFFSET_LIST_OUT].alist_name +			       == NULL) { +			listnode_delete(ripng_offset_list_master, offset); +			if (offset->ifname) +				free(offset->ifname); +			ripng_offset_list_free(offset); +		} +	} else { +		vty_out(vty, "Can't find offset-list\n"); +		return CMD_WARNING_CONFIG_FAILED;  	} -    } -  else -    { -      vty_out (vty, "Can't find offset-list\n"); -      return CMD_WARNING_CONFIG_FAILED; -    } -  return CMD_SUCCESS; +	return CMD_SUCCESS;  }  #define OFFSET_LIST_IN_NAME(O)  ((O)->direct[RIPNG_OFFSET_LIST_IN].alist_name) @@ -209,82 +193,80 @@ ripng_offset_list_unset (struct vty *vty, const char *alist,  #define OFFSET_LIST_OUT_METRIC(O)  ((O)->direct[RIPNG_OFFSET_LIST_OUT].metric)  /* If metric is modifed return 1. */ -int -ripng_offset_list_apply_in (struct prefix_ipv6 *p, struct interface *ifp, -			    u_char *metric) +int ripng_offset_list_apply_in(struct prefix_ipv6 *p, struct interface *ifp, +			       u_char *metric)  { -  struct ripng_offset_list *offset; -  struct access_list *alist; - -  /* Look up offset-list with interface name. */ -  offset = ripng_offset_list_lookup (ifp->name); -  if (offset && OFFSET_LIST_IN_NAME (offset)) -    { -      alist = access_list_lookup (AFI_IP6, OFFSET_LIST_IN_NAME (offset)); - -      if (alist  -	  && access_list_apply (alist, (struct prefix *)p) == FILTER_PERMIT) -	{ -	  *metric += OFFSET_LIST_IN_METRIC (offset); -	  return 1; +	struct ripng_offset_list *offset; +	struct access_list *alist; + +	/* Look up offset-list with interface name. */ +	offset = ripng_offset_list_lookup(ifp->name); +	if (offset && OFFSET_LIST_IN_NAME(offset)) { +		alist = access_list_lookup(AFI_IP6, +					   OFFSET_LIST_IN_NAME(offset)); + +		if (alist +		    && access_list_apply(alist, (struct prefix *)p) +			       == FILTER_PERMIT) { +			*metric += OFFSET_LIST_IN_METRIC(offset); +			return 1; +		} +		return 0;  	} -      return 0; -    } -  /* Look up offset-list without interface name. */ -  offset = ripng_offset_list_lookup (NULL); -  if (offset && OFFSET_LIST_IN_NAME (offset)) -    { -      alist = access_list_lookup (AFI_IP6, OFFSET_LIST_IN_NAME (offset)); - -      if (alist  -	  && access_list_apply (alist, (struct prefix *)p) == FILTER_PERMIT) -	{ -	  *metric += OFFSET_LIST_IN_METRIC (offset); -	  return 1; +	/* Look up offset-list without interface name. */ +	offset = ripng_offset_list_lookup(NULL); +	if (offset && OFFSET_LIST_IN_NAME(offset)) { +		alist = access_list_lookup(AFI_IP6, +					   OFFSET_LIST_IN_NAME(offset)); + +		if (alist +		    && access_list_apply(alist, (struct prefix *)p) +			       == FILTER_PERMIT) { +			*metric += OFFSET_LIST_IN_METRIC(offset); +			return 1; +		} +		return 0;  	} -      return 0; -    } -  return 0; +	return 0;  }  /* If metric is modifed return 1. */ -int -ripng_offset_list_apply_out (struct prefix_ipv6 *p, struct interface *ifp, -			     u_char *metric) +int ripng_offset_list_apply_out(struct prefix_ipv6 *p, struct interface *ifp, +				u_char *metric)  { -  struct ripng_offset_list *offset; -  struct access_list *alist; - -  /* Look up offset-list with interface name. */ -  offset = ripng_offset_list_lookup (ifp->name); -  if (offset && OFFSET_LIST_OUT_NAME (offset)) -    { -      alist = access_list_lookup (AFI_IP6, OFFSET_LIST_OUT_NAME (offset)); - -      if (alist  -	  && access_list_apply (alist, (struct prefix *)p) == FILTER_PERMIT) -	{ -	  *metric += OFFSET_LIST_OUT_METRIC (offset); -	  return 1; +	struct ripng_offset_list *offset; +	struct access_list *alist; + +	/* Look up offset-list with interface name. */ +	offset = ripng_offset_list_lookup(ifp->name); +	if (offset && OFFSET_LIST_OUT_NAME(offset)) { +		alist = access_list_lookup(AFI_IP6, +					   OFFSET_LIST_OUT_NAME(offset)); + +		if (alist +		    && access_list_apply(alist, (struct prefix *)p) +			       == FILTER_PERMIT) { +			*metric += OFFSET_LIST_OUT_METRIC(offset); +			return 1; +		} +		return 0;  	} -      return 0; -    } - -  /* Look up offset-list without interface name. */ -  offset = ripng_offset_list_lookup (NULL); -  if (offset && OFFSET_LIST_OUT_NAME (offset)) -    { -      alist = access_list_lookup (AFI_IP6, OFFSET_LIST_OUT_NAME (offset)); - -      if (alist  -	  && access_list_apply (alist, (struct prefix *)p) == FILTER_PERMIT) -	{ -	  *metric += OFFSET_LIST_OUT_METRIC (offset); -	  return 1; + +	/* Look up offset-list without interface name. */ +	offset = ripng_offset_list_lookup(NULL); +	if (offset && OFFSET_LIST_OUT_NAME(offset)) { +		alist = access_list_lookup(AFI_IP6, +					   OFFSET_LIST_OUT_NAME(offset)); + +		if (alist +		    && access_list_apply(alist, (struct prefix *)p) +			       == FILTER_PERMIT) { +			*metric += OFFSET_LIST_OUT_METRIC(offset); +			return 1; +		} +		return 0;  	} -      return 0; -    } -  return 0; +	return 0;  }  DEFUN (ripng_offset_list, @@ -296,10 +278,12 @@ DEFUN (ripng_offset_list,         "For outgoing updates\n"         "Metric value\n")  { -  int idx_word = 1; -  int idx_in_out = 2; -  int idx_number = 3; -  return ripng_offset_list_set (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, NULL); +	int idx_word = 1; +	int idx_in_out = 2; +	int idx_number = 3; +	return ripng_offset_list_set(vty, argv[idx_word]->arg, +				     argv[idx_in_out]->arg, +				     argv[idx_number]->arg, NULL);  }  DEFUN (ripng_offset_list_ifname, @@ -312,11 +296,13 @@ DEFUN (ripng_offset_list_ifname,         "Metric value\n"         "Interface to match\n")  { -  int idx_word = 1; -  int idx_in_out = 2; -  int idx_number = 3; -  int idx_ifname = 4; -  return ripng_offset_list_set (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, argv[idx_ifname]->arg); +	int idx_word = 1; +	int idx_in_out = 2; +	int idx_number = 3; +	int idx_ifname = 4; +	return ripng_offset_list_set( +		vty, argv[idx_word]->arg, argv[idx_in_out]->arg, +		argv[idx_number]->arg, argv[idx_ifname]->arg);  }  DEFUN (no_ripng_offset_list, @@ -329,10 +315,12 @@ DEFUN (no_ripng_offset_list,         "For outgoing updates\n"         "Metric value\n")  { -  int idx_word = 2; -  int idx_in_out = 3; -  int idx_number = 4; -  return ripng_offset_list_unset (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, NULL); +	int idx_word = 2; +	int idx_in_out = 3; +	int idx_number = 4; +	return ripng_offset_list_unset(vty, argv[idx_word]->arg, +				       argv[idx_in_out]->arg, +				       argv[idx_number]->arg, NULL);  }  DEFUN (no_ripng_offset_list_ifname, @@ -346,87 +334,91 @@ DEFUN (no_ripng_offset_list_ifname,         "Metric value\n"         "Interface to match\n")  { -  int idx_word = 2; -  int idx_in_out = 3; -  int idx_number = 4; -  int idx_ifname = 5; -  return ripng_offset_list_unset (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, argv[idx_ifname]->arg); +	int idx_word = 2; +	int idx_in_out = 3; +	int idx_number = 4; +	int idx_ifname = 5; +	return ripng_offset_list_unset( +		vty, argv[idx_word]->arg, argv[idx_in_out]->arg, +		argv[idx_number]->arg, argv[idx_ifname]->arg);  } -static int -offset_list_cmp (struct ripng_offset_list *o1, struct ripng_offset_list *o2) +static int offset_list_cmp(struct ripng_offset_list *o1, +			   struct ripng_offset_list *o2)  { -  return strcmp_safe (o1->ifname, o2->ifname); +	return strcmp_safe(o1->ifname, o2->ifname);  } -static void -offset_list_del (struct ripng_offset_list *offset) +static void offset_list_del(struct ripng_offset_list *offset)  { -  if (OFFSET_LIST_IN_NAME (offset)) -    free (OFFSET_LIST_IN_NAME (offset)); -  if (OFFSET_LIST_OUT_NAME (offset)) -    free (OFFSET_LIST_OUT_NAME (offset)); -  if (offset->ifname) -    free (offset->ifname); -  ripng_offset_list_free (offset); +	if (OFFSET_LIST_IN_NAME(offset)) +		free(OFFSET_LIST_IN_NAME(offset)); +	if (OFFSET_LIST_OUT_NAME(offset)) +		free(OFFSET_LIST_OUT_NAME(offset)); +	if (offset->ifname) +		free(offset->ifname); +	ripng_offset_list_free(offset);  } -void -ripng_offset_init (void) +void ripng_offset_init(void)  { -  ripng_offset_list_master = list_new (); -  ripng_offset_list_master->cmp = (int (*)(void *, void *)) offset_list_cmp; -  ripng_offset_list_master->del = (void (*)(void *)) offset_list_del; - -  install_element (RIPNG_NODE, &ripng_offset_list_cmd); -  install_element (RIPNG_NODE, &ripng_offset_list_ifname_cmd); -  install_element (RIPNG_NODE, &no_ripng_offset_list_cmd); -  install_element (RIPNG_NODE, &no_ripng_offset_list_ifname_cmd); +	ripng_offset_list_master = list_new(); +	ripng_offset_list_master->cmp = +		(int (*)(void *, void *))offset_list_cmp; +	ripng_offset_list_master->del = (void (*)(void *))offset_list_del; + +	install_element(RIPNG_NODE, &ripng_offset_list_cmd); +	install_element(RIPNG_NODE, &ripng_offset_list_ifname_cmd); +	install_element(RIPNG_NODE, &no_ripng_offset_list_cmd); +	install_element(RIPNG_NODE, &no_ripng_offset_list_ifname_cmd);  } -void -ripng_offset_clean (void) +void ripng_offset_clean(void)  { -  list_delete (ripng_offset_list_master); +	list_delete(ripng_offset_list_master); -  ripng_offset_list_master = list_new (); -  ripng_offset_list_master->cmp = (int (*)(void *, void *)) offset_list_cmp; -  ripng_offset_list_master->del = (void (*)(void *)) offset_list_del; +	ripng_offset_list_master = list_new(); +	ripng_offset_list_master->cmp = +		(int (*)(void *, void *))offset_list_cmp; +	ripng_offset_list_master->del = (void (*)(void *))offset_list_del;  } -int -config_write_ripng_offset_list (struct vty *vty) +int config_write_ripng_offset_list(struct vty *vty)  { -  struct listnode *node, *nnode; -  struct ripng_offset_list *offset; - -  for (ALL_LIST_ELEMENTS (ripng_offset_list_master, node, nnode, offset)) -    { -      if (! offset->ifname) -	{ -	  if (offset->direct[RIPNG_OFFSET_LIST_IN].alist_name) -	    vty_out (vty, " offset-list %s in %d\n", -		     offset->direct[RIPNG_OFFSET_LIST_IN].alist_name, -		     offset->direct[RIPNG_OFFSET_LIST_IN].metric); -	  if (offset->direct[RIPNG_OFFSET_LIST_OUT].alist_name) -	    vty_out (vty, " offset-list %s out %d\n", -		     offset->direct[RIPNG_OFFSET_LIST_OUT].alist_name, -		     offset->direct[RIPNG_OFFSET_LIST_OUT].metric); -	} -      else -	{ -	  if (offset->direct[RIPNG_OFFSET_LIST_IN].alist_name) -	    vty_out (vty, " offset-list %s in %d %s\n", -		     offset->direct[RIPNG_OFFSET_LIST_IN].alist_name, -		     offset->direct[RIPNG_OFFSET_LIST_IN].metric, -		     offset->ifname); -	  if (offset->direct[RIPNG_OFFSET_LIST_OUT].alist_name) -	    vty_out (vty, " offset-list %s out %d %s\n", -		     offset->direct[RIPNG_OFFSET_LIST_OUT].alist_name, -		     offset->direct[RIPNG_OFFSET_LIST_OUT].metric, -		     offset->ifname); +	struct listnode *node, *nnode; +	struct ripng_offset_list *offset; + +	for (ALL_LIST_ELEMENTS(ripng_offset_list_master, node, nnode, offset)) { +		if (!offset->ifname) { +			if (offset->direct[RIPNG_OFFSET_LIST_IN].alist_name) +				vty_out(vty, " offset-list %s in %d\n", +					offset->direct[RIPNG_OFFSET_LIST_IN] +						.alist_name, +					offset->direct[RIPNG_OFFSET_LIST_IN] +						.metric); +			if (offset->direct[RIPNG_OFFSET_LIST_OUT].alist_name) +				vty_out(vty, " offset-list %s out %d\n", +					offset->direct[RIPNG_OFFSET_LIST_OUT] +						.alist_name, +					offset->direct[RIPNG_OFFSET_LIST_OUT] +						.metric); +		} else { +			if (offset->direct[RIPNG_OFFSET_LIST_IN].alist_name) +				vty_out(vty, " offset-list %s in %d %s\n", +					offset->direct[RIPNG_OFFSET_LIST_IN] +						.alist_name, +					offset->direct[RIPNG_OFFSET_LIST_IN] +						.metric, +					offset->ifname); +			if (offset->direct[RIPNG_OFFSET_LIST_OUT].alist_name) +				vty_out(vty, " offset-list %s out %d %s\n", +					offset->direct[RIPNG_OFFSET_LIST_OUT] +						.alist_name, +					offset->direct[RIPNG_OFFSET_LIST_OUT] +						.metric, +					offset->ifname); +		}  	} -    } -  return 0; +	return 0;  } diff --git a/ripngd/ripng_peer.c b/ripngd/ripng_peer.c index f27c33f37c..2a412f9b64 100644 --- a/ripngd/ripng_peer.c +++ b/ripngd/ripng_peer.c @@ -38,178 +38,157 @@  /* Linked list of RIPng peer. */  struct list *peer_list; -static struct ripng_peer * -ripng_peer_new (void) +static struct ripng_peer *ripng_peer_new(void)  { -  return XCALLOC (MTYPE_RIPNG_PEER, sizeof (struct ripng_peer)); +	return XCALLOC(MTYPE_RIPNG_PEER, sizeof(struct ripng_peer));  } -static void -ripng_peer_free (struct ripng_peer *peer) +static void ripng_peer_free(struct ripng_peer *peer)  { -  XFREE (MTYPE_RIPNG_PEER, peer); +	XFREE(MTYPE_RIPNG_PEER, peer);  } -struct ripng_peer * -ripng_peer_lookup (struct in6_addr *addr) +struct ripng_peer *ripng_peer_lookup(struct in6_addr *addr)  { -  struct ripng_peer *peer; -  struct listnode *node, *nnode; - -  for (ALL_LIST_ELEMENTS (peer_list, node, nnode, peer)) -    { -      if (IPV6_ADDR_SAME (&peer->addr, addr)) -	return peer; -    } -  return NULL; +	struct ripng_peer *peer; +	struct listnode *node, *nnode; + +	for (ALL_LIST_ELEMENTS(peer_list, node, nnode, peer)) { +		if (IPV6_ADDR_SAME(&peer->addr, addr)) +			return peer; +	} +	return NULL;  } -struct ripng_peer * -ripng_peer_lookup_next (struct in6_addr *addr) +struct ripng_peer *ripng_peer_lookup_next(struct in6_addr *addr)  { -  struct ripng_peer *peer; -  struct listnode *node, *nnode; - -  for (ALL_LIST_ELEMENTS (peer_list, node, nnode, peer)) -    { -      if (addr6_cmp(&peer->addr, addr) > 0)  -	return peer; -    } -  return NULL; +	struct ripng_peer *peer; +	struct listnode *node, *nnode; + +	for (ALL_LIST_ELEMENTS(peer_list, node, nnode, peer)) { +		if (addr6_cmp(&peer->addr, addr) > 0) +			return peer; +	} +	return NULL;  }  /* RIPng peer is timeout.   * Garbage collector.   **/ -static int -ripng_peer_timeout (struct thread *t) +static int ripng_peer_timeout(struct thread *t)  { -  struct ripng_peer *peer; +	struct ripng_peer *peer; -  peer = THREAD_ARG (t); -  listnode_delete (peer_list, peer); -  ripng_peer_free (peer); +	peer = THREAD_ARG(t); +	listnode_delete(peer_list, peer); +	ripng_peer_free(peer); -  return 0; +	return 0;  }  /* Get RIPng peer.  At the same time update timeout thread. */ -static struct ripng_peer * -ripng_peer_get (struct in6_addr *addr) +static struct ripng_peer *ripng_peer_get(struct in6_addr *addr)  { -  struct ripng_peer *peer; - -  peer = ripng_peer_lookup (addr); - -  if (peer) -    { -      if (peer->t_timeout) -	thread_cancel (peer->t_timeout); -    } -  else -    { -      peer = ripng_peer_new (); -      peer->addr = *addr; /* XXX */ -      listnode_add_sort (peer_list, peer); -    } - -  /* Update timeout thread. */ -  peer->t_timeout = NULL; -  thread_add_timer(master, ripng_peer_timeout, peer, RIPNG_PEER_TIMER_DEFAULT, -                   &peer->t_timeout); - -  /* Last update time set. */ -  time (&peer->uptime); -   -  return peer; +	struct ripng_peer *peer; + +	peer = ripng_peer_lookup(addr); + +	if (peer) { +		if (peer->t_timeout) +			thread_cancel(peer->t_timeout); +	} else { +		peer = ripng_peer_new(); +		peer->addr = *addr; /* XXX */ +		listnode_add_sort(peer_list, peer); +	} + +	/* Update timeout thread. */ +	peer->t_timeout = NULL; +	thread_add_timer(master, ripng_peer_timeout, peer, +			 RIPNG_PEER_TIMER_DEFAULT, &peer->t_timeout); + +	/* Last update time set. */ +	time(&peer->uptime); + +	return peer;  } -void -ripng_peer_update (struct sockaddr_in6 *from, u_char version) +void ripng_peer_update(struct sockaddr_in6 *from, u_char version)  { -  struct ripng_peer *peer; -  peer = ripng_peer_get (&from->sin6_addr); -  peer->version = version; +	struct ripng_peer *peer; +	peer = ripng_peer_get(&from->sin6_addr); +	peer->version = version;  } -void -ripng_peer_bad_route (struct sockaddr_in6 *from) +void ripng_peer_bad_route(struct sockaddr_in6 *from)  { -  struct ripng_peer *peer; -  peer = ripng_peer_get (&from->sin6_addr); -  peer->recv_badroutes++; +	struct ripng_peer *peer; +	peer = ripng_peer_get(&from->sin6_addr); +	peer->recv_badroutes++;  } -void -ripng_peer_bad_packet (struct sockaddr_in6 *from) +void ripng_peer_bad_packet(struct sockaddr_in6 *from)  { -  struct ripng_peer *peer; -  peer = ripng_peer_get (&from->sin6_addr); -  peer->recv_badpackets++; +	struct ripng_peer *peer; +	peer = ripng_peer_get(&from->sin6_addr); +	peer->recv_badpackets++;  }  /* Display peer uptime. */ -static char * -ripng_peer_uptime (struct ripng_peer *peer, char *buf, size_t len) +static char *ripng_peer_uptime(struct ripng_peer *peer, char *buf, size_t len)  { -  time_t uptime; -  struct tm *tm; - -  /* If there is no connection has been done before print `never'. */ -  if (peer->uptime == 0) -    { -      snprintf (buf, len, "never   "); -      return buf; -    } - -  /* Get current time. */ -  uptime = time (NULL); -  uptime -= peer->uptime; -  tm = gmtime (&uptime); - -  /* Making formatted timer strings. */ +	time_t uptime; +	struct tm *tm; + +	/* If there is no connection has been done before print `never'. */ +	if (peer->uptime == 0) { +		snprintf(buf, len, "never   "); +		return buf; +	} + +	/* Get current time. */ +	uptime = time(NULL); +	uptime -= peer->uptime; +	tm = gmtime(&uptime); + +/* Making formatted timer strings. */  #define ONE_DAY_SECOND 60*60*24  #define ONE_WEEK_SECOND 60*60*24*7 -  if (uptime < ONE_DAY_SECOND) -    snprintf (buf, len, "%02d:%02d:%02d",  -	      tm->tm_hour, tm->tm_min, tm->tm_sec); -  else if (uptime < ONE_WEEK_SECOND) -    snprintf (buf, len, "%dd%02dh%02dm",  -	      tm->tm_yday, tm->tm_hour, tm->tm_min); -  else -    snprintf (buf, len, "%02dw%dd%02dh",  -	      tm->tm_yday/7, tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour); -  return buf; +	if (uptime < ONE_DAY_SECOND) +		snprintf(buf, len, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, +			 tm->tm_sec); +	else if (uptime < ONE_WEEK_SECOND) +		snprintf(buf, len, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour, +			 tm->tm_min); +	else +		snprintf(buf, len, "%02dw%dd%02dh", tm->tm_yday / 7, +			 tm->tm_yday - ((tm->tm_yday / 7) * 7), tm->tm_hour); +	return buf;  } -void -ripng_peer_display (struct vty *vty) +void ripng_peer_display(struct vty *vty)  { -  struct ripng_peer *peer; -  struct listnode *node, *nnode; +	struct ripng_peer *peer; +	struct listnode *node, *nnode;  #define RIPNG_UPTIME_LEN 25 -  char timebuf[RIPNG_UPTIME_LEN]; - -  for (ALL_LIST_ELEMENTS (peer_list, node, nnode, peer)) -    { -      vty_out (vty, "    %s \n%14s %10d %10d %10d      %s\n", inet6_ntoa (peer->addr), -               " ", -	       peer->recv_badpackets, peer->recv_badroutes, -	       ZEBRA_RIPNG_DISTANCE_DEFAULT, -	       ripng_peer_uptime(peer, timebuf, RIPNG_UPTIME_LEN)); -    } +	char timebuf[RIPNG_UPTIME_LEN]; + +	for (ALL_LIST_ELEMENTS(peer_list, node, nnode, peer)) { +		vty_out(vty, "    %s \n%14s %10d %10d %10d      %s\n", +			inet6_ntoa(peer->addr), " ", peer->recv_badpackets, +			peer->recv_badroutes, ZEBRA_RIPNG_DISTANCE_DEFAULT, +			ripng_peer_uptime(peer, timebuf, RIPNG_UPTIME_LEN)); +	}  } -static int -ripng_peer_list_cmp (struct ripng_peer *p1, struct ripng_peer *p2) +static int ripng_peer_list_cmp(struct ripng_peer *p1, struct ripng_peer *p2)  { -  return addr6_cmp(&p1->addr, &p2->addr) > 0; +	return addr6_cmp(&p1->addr, &p2->addr) > 0;  } -void -ripng_peer_init () +void ripng_peer_init()  { -  peer_list = list_new (); -  peer_list->cmp = (int (*)(void *, void *)) ripng_peer_list_cmp; +	peer_list = list_new(); +	peer_list->cmp = (int (*)(void *, void *))ripng_peer_list_cmp;  } diff --git a/ripngd/ripng_route.c b/ripngd/ripng_route.c index f7d3ef89f4..83cb59c8b8 100644 --- a/ripngd/ripng_route.c +++ b/ripngd/ripng_route.c @@ -30,151 +30,138 @@  #include "ripngd/ripngd.h"  #include "ripngd/ripng_route.h" -static struct ripng_aggregate * -ripng_aggregate_new (void) +static struct ripng_aggregate *ripng_aggregate_new(void)  { -  struct ripng_aggregate *new; +	struct ripng_aggregate *new; -  new = XCALLOC (MTYPE_RIPNG_AGGREGATE, sizeof (struct ripng_aggregate)); -  return new; +	new = XCALLOC(MTYPE_RIPNG_AGGREGATE, sizeof(struct ripng_aggregate)); +	return new;  } -void -ripng_aggregate_free (struct ripng_aggregate *aggregate) +void ripng_aggregate_free(struct ripng_aggregate *aggregate)  { -  XFREE (MTYPE_RIPNG_AGGREGATE, aggregate); +	XFREE(MTYPE_RIPNG_AGGREGATE, aggregate);  }  /* Aggregate count increment check. */ -void -ripng_aggregate_increment (struct route_node *child, struct ripng_info *rinfo) +void ripng_aggregate_increment(struct route_node *child, +			       struct ripng_info *rinfo)  { -  struct route_node *np; -  struct ripng_aggregate *aggregate; - -  for (np = child; np; np = np->parent) -    if ((aggregate = np->aggregate) != NULL) -      { -	aggregate->count++; -	rinfo->suppress++; -      } +	struct route_node *np; +	struct ripng_aggregate *aggregate; + +	for (np = child; np; np = np->parent) +		if ((aggregate = np->aggregate) != NULL) { +			aggregate->count++; +			rinfo->suppress++; +		}  }  /* Aggregate count decrement check. */ -void -ripng_aggregate_decrement (struct route_node *child, struct ripng_info *rinfo) +void ripng_aggregate_decrement(struct route_node *child, +			       struct ripng_info *rinfo)  { -  struct route_node *np; -  struct ripng_aggregate *aggregate; - -  for (np = child; np; np = np->parent) -    if ((aggregate = np->aggregate) != NULL) -      { -	aggregate->count--; -	rinfo->suppress--; -      } +	struct route_node *np; +	struct ripng_aggregate *aggregate; + +	for (np = child; np; np = np->parent) +		if ((aggregate = np->aggregate) != NULL) { +			aggregate->count--; +			rinfo->suppress--; +		}  }  /* Aggregate count decrement check for a list. */ -void -ripng_aggregate_decrement_list (struct route_node *child, struct list *list) +void ripng_aggregate_decrement_list(struct route_node *child, struct list *list)  { -  struct route_node *np; -  struct ripng_aggregate *aggregate; -  struct ripng_info *rinfo = NULL; -  struct listnode *node = NULL; +	struct route_node *np; +	struct ripng_aggregate *aggregate; +	struct ripng_info *rinfo = NULL; +	struct listnode *node = NULL; -  for (np = child; np; np = np->parent) -    if ((aggregate = np->aggregate) != NULL) -      aggregate->count -= listcount (list); +	for (np = child; np; np = np->parent) +		if ((aggregate = np->aggregate) != NULL) +			aggregate->count -= listcount(list); -  for (ALL_LIST_ELEMENTS_RO (list, node, rinfo)) -    rinfo->suppress--; +	for (ALL_LIST_ELEMENTS_RO(list, node, rinfo)) +		rinfo->suppress--;  }  /* RIPng routes treatment. */ -int -ripng_aggregate_add (struct prefix *p) +int ripng_aggregate_add(struct prefix *p)  { -  struct route_node *top; -  struct route_node *rp; -  struct ripng_info *rinfo; -  struct ripng_aggregate *aggregate; -  struct ripng_aggregate *sub; -  struct list *list = NULL; -  struct listnode *node = NULL; - -  /* Get top node for aggregation. */ -  top = route_node_get (ripng->table, p); - -  /* Allocate new aggregate. */ -  aggregate = ripng_aggregate_new (); -  aggregate->metric = 1; - -  top->aggregate = aggregate; - -  /* Suppress routes match to the aggregate. */ -  for (rp = route_lock_node (top); rp; rp = route_next_until (rp, top)) -    { -      /* Suppress normal route. */ -      if ((list = rp->info) != NULL) -        for (ALL_LIST_ELEMENTS_RO (list, node, rinfo)) -          { -            aggregate->count++; -            rinfo->suppress++; -          } -      /* Suppress aggregate route.  This may not need. */ -      if (rp != top && (sub = rp->aggregate) != NULL) -	{ -	  aggregate->count++; -	  sub->suppress++; +	struct route_node *top; +	struct route_node *rp; +	struct ripng_info *rinfo; +	struct ripng_aggregate *aggregate; +	struct ripng_aggregate *sub; +	struct list *list = NULL; +	struct listnode *node = NULL; + +	/* Get top node for aggregation. */ +	top = route_node_get(ripng->table, p); + +	/* Allocate new aggregate. */ +	aggregate = ripng_aggregate_new(); +	aggregate->metric = 1; + +	top->aggregate = aggregate; + +	/* Suppress routes match to the aggregate. */ +	for (rp = route_lock_node(top); rp; rp = route_next_until(rp, top)) { +		/* Suppress normal route. */ +		if ((list = rp->info) != NULL) +			for (ALL_LIST_ELEMENTS_RO(list, node, rinfo)) { +				aggregate->count++; +				rinfo->suppress++; +			} +		/* Suppress aggregate route.  This may not need. */ +		if (rp != top && (sub = rp->aggregate) != NULL) { +			aggregate->count++; +			sub->suppress++; +		}  	} -    } -  return 0; +	return 0;  }  /* Delete RIPng static route. */ -int -ripng_aggregate_delete (struct prefix *p) +int ripng_aggregate_delete(struct prefix *p)  { -  struct route_node *top; -  struct route_node *rp; -  struct ripng_info *rinfo; -  struct ripng_aggregate *aggregate; -  struct ripng_aggregate *sub; -  struct list *list = NULL; -  struct listnode *node = NULL; - -  /* Get top node for aggregation. */ -  top = route_node_get (ripng->table, p); - -  /* Allocate new aggregate. */ -  aggregate = top->aggregate; - -  /* Suppress routes match to the aggregate. */ -  for (rp = route_lock_node (top); rp; rp = route_next_until (rp, top)) -    { -      /* Suppress normal route. */ -      if ((list = rp->info) != NULL) -        for (ALL_LIST_ELEMENTS_RO (list, node, rinfo)) -          { -            aggregate->count--; -            rinfo->suppress--; -          } - -      if (rp != top && (sub = rp->aggregate) != NULL) -	{ -	  aggregate->count--; -	  sub->suppress--; +	struct route_node *top; +	struct route_node *rp; +	struct ripng_info *rinfo; +	struct ripng_aggregate *aggregate; +	struct ripng_aggregate *sub; +	struct list *list = NULL; +	struct listnode *node = NULL; + +	/* Get top node for aggregation. */ +	top = route_node_get(ripng->table, p); + +	/* Allocate new aggregate. */ +	aggregate = top->aggregate; + +	/* Suppress routes match to the aggregate. */ +	for (rp = route_lock_node(top); rp; rp = route_next_until(rp, top)) { +		/* Suppress normal route. */ +		if ((list = rp->info) != NULL) +			for (ALL_LIST_ELEMENTS_RO(list, node, rinfo)) { +				aggregate->count--; +				rinfo->suppress--; +			} + +		if (rp != top && (sub = rp->aggregate) != NULL) { +			aggregate->count--; +			sub->suppress--; +		}  	} -    } -  top->aggregate = NULL; -  ripng_aggregate_free (aggregate); +	top->aggregate = NULL; +	ripng_aggregate_free(aggregate); -  route_unlock_node (top); -  route_unlock_node (top); +	route_unlock_node(top); +	route_unlock_node(top); -  return 0; +	return 0;  } diff --git a/ripngd/ripng_route.h b/ripngd/ripng_route.h index 90dae04700..3db1279b5c 100644 --- a/ripngd/ripng_route.h +++ b/ripngd/ripng_route.h @@ -22,35 +22,34 @@  #ifndef _ZEBRA_RIPNG_ROUTE_H  #define _ZEBRA_RIPNG_ROUTE_H -struct ripng_aggregate -{ -  /* Aggregate route count. */ -  unsigned int count; +struct ripng_aggregate { +	/* Aggregate route count. */ +	unsigned int count; -  /* Suppressed route count. */ -  unsigned int suppress; +	/* Suppressed route count. */ +	unsigned int suppress; -  /* Metric of this route.  */ -  u_char metric;		 +	/* Metric of this route.  */ +	u_char metric; -  /* Tag field of RIPng packet.*/ -  u_int16_t tag; +	/* Tag field of RIPng packet.*/ +	u_int16_t tag; -  /* Route-map futures - this variables can be changed. */ -  struct in6_addr nexthop_out; -  u_char metric_set; -  u_char metric_out; -  u_int16_t tag_out; +	/* Route-map futures - this variables can be changed. */ +	struct in6_addr nexthop_out; +	u_char metric_set; +	u_char metric_out; +	u_int16_t tag_out;  }; -extern void ripng_aggregate_increment (struct route_node *rp, -                                       struct ripng_info *rinfo); -extern void ripng_aggregate_decrement (struct route_node *rp, -                                       struct ripng_info *rinfo); -extern void ripng_aggregate_decrement_list (struct route_node *rp, -                                       struct list *list); -extern int ripng_aggregate_add (struct prefix *p); -extern int ripng_aggregate_delete (struct prefix *p); -extern void ripng_aggregate_free (struct ripng_aggregate *aggregate); +extern void ripng_aggregate_increment(struct route_node *rp, +				      struct ripng_info *rinfo); +extern void ripng_aggregate_decrement(struct route_node *rp, +				      struct ripng_info *rinfo); +extern void ripng_aggregate_decrement_list(struct route_node *rp, +					   struct list *list); +extern int ripng_aggregate_add(struct prefix *p); +extern int ripng_aggregate_delete(struct prefix *p); +extern void ripng_aggregate_free(struct ripng_aggregate *aggregate);  #endif /* _ZEBRA_RIPNG_ROUTE_H */ diff --git a/ripngd/ripng_routemap.c b/ripngd/ripng_routemap.c index 69ff84b220..3080801fb3 100644 --- a/ripngd/ripng_routemap.c +++ b/ripngd/ripng_routemap.c @@ -30,383 +30,335 @@  #include "ripngd/ripngd.h" -struct rip_metric_modifier -{ -  enum  -  { -    metric_increment, -    metric_decrement, -    metric_absolute -  } type; - -  u_char metric; +struct rip_metric_modifier { +	enum { metric_increment, metric_decrement, metric_absolute } type; + +	u_char metric;  };  /* `match metric METRIC' */  /* Match function return 1 if match is success else return zero. */ -static route_map_result_t -route_match_metric (void *rule, struct prefix *prefix,  -		    route_map_object_t type, void *object) +static route_map_result_t route_match_metric(void *rule, struct prefix *prefix, +					     route_map_object_t type, +					     void *object)  { -  u_int32_t *metric; -  struct ripng_info *rinfo; - -  if (type == RMAP_RIPNG) -    { -      metric = rule; -      rinfo = object; -     -      if (rinfo->metric == *metric) -	return RMAP_MATCH; -      else +	u_int32_t *metric; +	struct ripng_info *rinfo; + +	if (type == RMAP_RIPNG) { +		metric = rule; +		rinfo = object; + +		if (rinfo->metric == *metric) +			return RMAP_MATCH; +		else +			return RMAP_NOMATCH; +	}  	return RMAP_NOMATCH; -    } -  return RMAP_NOMATCH;  }  /* Route map `match metric' match statement. `arg' is METRIC value */ -static void * -route_match_metric_compile (const char *arg) +static void *route_match_metric_compile(const char *arg)  { -  u_int32_t *metric; +	u_int32_t *metric; -  metric = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t)); -  *metric = atoi (arg); +	metric = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(u_int32_t)); +	*metric = atoi(arg); -  if(*metric > 0) -    return metric; +	if (*metric > 0) +		return metric; -  XFREE (MTYPE_ROUTE_MAP_COMPILED, metric); -  return NULL; +	XFREE(MTYPE_ROUTE_MAP_COMPILED, metric); +	return NULL;  }  /* Free route map's compiled `match metric' value. */ -static void -route_match_metric_free (void *rule) +static void route_match_metric_free(void *rule)  { -  XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); +	XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);  }  /* Route map commands for metric matching. */ -static struct route_map_rule_cmd route_match_metric_cmd = -{ -  "metric", -  route_match_metric, -  route_match_metric_compile, -  route_match_metric_free -}; +static struct route_map_rule_cmd route_match_metric_cmd = { +	"metric", route_match_metric, route_match_metric_compile, +	route_match_metric_free};  /* `match interface IFNAME' */  /* Match function return 1 if match is success else return zero. */ -static route_map_result_t -route_match_interface (void *rule, struct prefix *prefix, -		       route_map_object_t type, void *object) +static route_map_result_t route_match_interface(void *rule, +						struct prefix *prefix, +						route_map_object_t type, +						void *object)  { -  struct ripng_info *rinfo; -  struct interface *ifp; -  char *ifname; +	struct ripng_info *rinfo; +	struct interface *ifp; +	char *ifname; -  if (type == RMAP_RIPNG) -    { -      ifname = rule; -      ifp = if_lookup_by_name(ifname, VRF_DEFAULT); +	if (type == RMAP_RIPNG) { +		ifname = rule; +		ifp = if_lookup_by_name(ifname, VRF_DEFAULT); -      if (!ifp) -	return RMAP_NOMATCH; +		if (!ifp) +			return RMAP_NOMATCH; -      rinfo = object; +		rinfo = object; -      if (rinfo->ifindex == ifp->ifindex) -	return RMAP_MATCH; -      else +		if (rinfo->ifindex == ifp->ifindex) +			return RMAP_MATCH; +		else +			return RMAP_NOMATCH; +	}  	return RMAP_NOMATCH; -    } -  return RMAP_NOMATCH;  }  /* Route map `match interface' match statement. `arg' is IFNAME value */ -static void * -route_match_interface_compile (const char *arg) +static void *route_match_interface_compile(const char *arg)  { -  return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg); +	return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg);  } -static void -route_match_interface_free (void *rule) +static void route_match_interface_free(void *rule)  { -  XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); +	XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);  } -static struct route_map_rule_cmd route_match_interface_cmd = -{ -  "interface", -  route_match_interface, -  route_match_interface_compile, -  route_match_interface_free -}; +static struct route_map_rule_cmd route_match_interface_cmd = { +	"interface", route_match_interface, route_match_interface_compile, +	route_match_interface_free};  /* `match tag TAG' */  /* Match function return 1 if match is success else return zero. */ -static route_map_result_t -route_match_tag (void *rule, struct prefix *prefix,  -		    route_map_object_t type, void *object) +static route_map_result_t route_match_tag(void *rule, struct prefix *prefix, +					  route_map_object_t type, void *object)  { -  route_tag_t *tag; -  struct ripng_info *rinfo; -  route_tag_t rinfo_tag; - -  if (type == RMAP_RIPNG) -    { -      tag = rule; -      rinfo = object; - -      /* The information stored by rinfo is host ordered. */ -      rinfo_tag = rinfo->tag; -      if (rinfo_tag == *tag) -	return RMAP_MATCH; -      else +	route_tag_t *tag; +	struct ripng_info *rinfo; +	route_tag_t rinfo_tag; + +	if (type == RMAP_RIPNG) { +		tag = rule; +		rinfo = object; + +		/* The information stored by rinfo is host ordered. */ +		rinfo_tag = rinfo->tag; +		if (rinfo_tag == *tag) +			return RMAP_MATCH; +		else +			return RMAP_NOMATCH; +	}  	return RMAP_NOMATCH; -    } -  return RMAP_NOMATCH;  } -static struct route_map_rule_cmd route_match_tag_cmd = -{ -  "tag", -  route_match_tag, -  route_map_rule_tag_compile, -  route_map_rule_tag_free, +static struct route_map_rule_cmd route_match_tag_cmd = { +	"tag", route_match_tag, route_map_rule_tag_compile, +	route_map_rule_tag_free,  };  /* `set metric METRIC' */  /* Set metric to attribute. */ -static route_map_result_t -route_set_metric (void *rule, struct prefix *prefix,  -		  route_map_object_t type, void *object) +static route_map_result_t route_set_metric(void *rule, struct prefix *prefix, +					   route_map_object_t type, +					   void *object)  { -  if (type == RMAP_RIPNG) -    { -      struct rip_metric_modifier *mod; -      struct ripng_info *rinfo; - -      mod = rule; -      rinfo = object; - -      if (mod->type == metric_increment) -	rinfo->metric_out += mod->metric; -      else if (mod->type == metric_decrement) -	rinfo->metric_out-= mod->metric; -      else if (mod->type == metric_absolute) -	rinfo->metric_out = mod->metric; - -      if (rinfo->metric_out < 1) -	rinfo->metric_out = 1; -      if (rinfo->metric_out > RIPNG_METRIC_INFINITY) -	rinfo->metric_out = RIPNG_METRIC_INFINITY; - -      rinfo->metric_set = 1; -    } -  return RMAP_OKAY; +	if (type == RMAP_RIPNG) { +		struct rip_metric_modifier *mod; +		struct ripng_info *rinfo; + +		mod = rule; +		rinfo = object; + +		if (mod->type == metric_increment) +			rinfo->metric_out += mod->metric; +		else if (mod->type == metric_decrement) +			rinfo->metric_out -= mod->metric; +		else if (mod->type == metric_absolute) +			rinfo->metric_out = mod->metric; + +		if (rinfo->metric_out < 1) +			rinfo->metric_out = 1; +		if (rinfo->metric_out > RIPNG_METRIC_INFINITY) +			rinfo->metric_out = RIPNG_METRIC_INFINITY; + +		rinfo->metric_set = 1; +	} +	return RMAP_OKAY;  }  /* set metric compilation. */ -static void * -route_set_metric_compile (const char *arg) +static void *route_set_metric_compile(const char *arg)  { -  int len; -  const char *pnt; -  int type; -  long metric; -  char *endptr = NULL; -  struct rip_metric_modifier *mod; - -  len = strlen (arg); -  pnt = arg; - -  if (len == 0) -    return NULL; - -  /* Examine first character. */ -  if (arg[0] == '+') -    { -      type = metric_increment; -      pnt++; -    } -  else if (arg[0] == '-') -    { -      type = metric_decrement; -      pnt++; -    } -  else -    type = metric_absolute; - -  /* Check beginning with digit string. */ -  if (*pnt < '0' || *pnt > '9') -    return NULL; - -  /* Convert string to integer. */ -  metric = strtol (pnt, &endptr, 10); - -  if (metric == LONG_MAX || *endptr != '\0') -    return NULL; -  /* Commented out by Hasso Tepper, to avoid problems in vtysh. */ -  /* if (metric < 0 || metric > RIPNG_METRIC_INFINITY) */ -  if (metric < 0) -    return NULL; - -  mod = XMALLOC (MTYPE_ROUTE_MAP_COMPILED,  -		 sizeof (struct rip_metric_modifier)); -  mod->type = type; -  mod->metric = metric; - -  return mod; +	int len; +	const char *pnt; +	int type; +	long metric; +	char *endptr = NULL; +	struct rip_metric_modifier *mod; + +	len = strlen(arg); +	pnt = arg; + +	if (len == 0) +		return NULL; + +	/* Examine first character. */ +	if (arg[0] == '+') { +		type = metric_increment; +		pnt++; +	} else if (arg[0] == '-') { +		type = metric_decrement; +		pnt++; +	} else +		type = metric_absolute; + +	/* Check beginning with digit string. */ +	if (*pnt < '0' || *pnt > '9') +		return NULL; + +	/* Convert string to integer. */ +	metric = strtol(pnt, &endptr, 10); + +	if (metric == LONG_MAX || *endptr != '\0') +		return NULL; +	/* Commented out by Hasso Tepper, to avoid problems in vtysh. */ +	/* if (metric < 0 || metric > RIPNG_METRIC_INFINITY) */ +	if (metric < 0) +		return NULL; + +	mod = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, +		      sizeof(struct rip_metric_modifier)); +	mod->type = type; +	mod->metric = metric; + +	return mod;  }  /* Free route map's compiled `set metric' value. */ -static void -route_set_metric_free (void *rule) +static void route_set_metric_free(void *rule)  { -  XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); +	XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);  } -static struct route_map_rule_cmd route_set_metric_cmd =  -{ -  "metric", -  route_set_metric, -  route_set_metric_compile, -  route_set_metric_free, +static struct route_map_rule_cmd route_set_metric_cmd = { +	"metric", route_set_metric, route_set_metric_compile, +	route_set_metric_free,  };  /* `set ipv6 next-hop local IP_ADDRESS' */  /* Set nexthop to object.  ojbect must be pointer to struct attr. */ -static route_map_result_t -route_set_ipv6_nexthop_local (void *rule, struct prefix *prefix,  -		      route_map_object_t type, void *object) +static route_map_result_t route_set_ipv6_nexthop_local(void *rule, +						       struct prefix *prefix, +						       route_map_object_t type, +						       void *object)  { -  struct in6_addr *address; -  struct ripng_info *rinfo; - -  if(type == RMAP_RIPNG) -    { -      /* Fetch routemap's rule information. */ -      address = rule; -      rinfo = object; -     -      /* Set next hop value. */  -      rinfo->nexthop_out = *address; -    } - -  return RMAP_OKAY; +	struct in6_addr *address; +	struct ripng_info *rinfo; + +	if (type == RMAP_RIPNG) { +		/* Fetch routemap's rule information. */ +		address = rule; +		rinfo = object; + +		/* Set next hop value. */ +		rinfo->nexthop_out = *address; +	} + +	return RMAP_OKAY;  }  /* Route map `ipv6 nexthop local' compile function.  Given string is converted     to struct in6_addr structure. */ -static void * -route_set_ipv6_nexthop_local_compile (const char *arg) +static void *route_set_ipv6_nexthop_local_compile(const char *arg)  { -  int ret; -  struct in6_addr *address; +	int ret; +	struct in6_addr *address; -  address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct in6_addr)); +	address = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(struct in6_addr)); -  ret = inet_pton (AF_INET6, arg, address); +	ret = inet_pton(AF_INET6, arg, address); -  if (ret == 0) -    { -      XFREE (MTYPE_ROUTE_MAP_COMPILED, address); -      return NULL; -    } +	if (ret == 0) { +		XFREE(MTYPE_ROUTE_MAP_COMPILED, address); +		return NULL; +	} -  return address; +	return address;  }  /* Free route map's compiled `ipv6 nexthop local' value. */ -static void -route_set_ipv6_nexthop_local_free (void *rule) +static void route_set_ipv6_nexthop_local_free(void *rule)  { -  XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); +	XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);  }  /* Route map commands for ipv6 nexthop local set. */ -static struct route_map_rule_cmd route_set_ipv6_nexthop_local_cmd = -{ -  "ipv6 next-hop local", -  route_set_ipv6_nexthop_local, -  route_set_ipv6_nexthop_local_compile, -  route_set_ipv6_nexthop_local_free -}; +static struct route_map_rule_cmd route_set_ipv6_nexthop_local_cmd = { +	"ipv6 next-hop local", route_set_ipv6_nexthop_local, +	route_set_ipv6_nexthop_local_compile, +	route_set_ipv6_nexthop_local_free};  /* `set tag TAG' */  /* Set tag to object.  ojbect must be pointer to struct attr. */ -static route_map_result_t -route_set_tag (void *rule, struct prefix *prefix,  -		      route_map_object_t type, void *object) +static route_map_result_t route_set_tag(void *rule, struct prefix *prefix, +					route_map_object_t type, void *object)  { -  route_tag_t *tag; -  struct ripng_info *rinfo; - -  if(type == RMAP_RIPNG) -    { -      /* Fetch routemap's rule information. */ -      tag = rule; -      rinfo = object; -     -      /* Set next hop value. */  -      rinfo->tag_out = *tag; -    } - -  return RMAP_OKAY; +	route_tag_t *tag; +	struct ripng_info *rinfo; + +	if (type == RMAP_RIPNG) { +		/* Fetch routemap's rule information. */ +		tag = rule; +		rinfo = object; + +		/* Set next hop value. */ +		rinfo->tag_out = *tag; +	} + +	return RMAP_OKAY;  }  /* Route map commands for tag set. */ -static struct route_map_rule_cmd route_set_tag_cmd = -{ -  "tag", -  route_set_tag, -  route_map_rule_tag_compile, -  route_map_rule_tag_free -}; +static struct route_map_rule_cmd route_set_tag_cmd = { +	"tag", route_set_tag, route_map_rule_tag_compile, +	route_map_rule_tag_free};  #define MATCH_STR "Match values from routing table\n"  #define SET_STR "Set values in destination routing protocol\n" -void -ripng_route_map_reset () +void ripng_route_map_reset()  { -  /* XXX ??? */ -  ; +	/* XXX ??? */ +	;  } -void -ripng_route_map_init () +void ripng_route_map_init()  { -  route_map_init (); +	route_map_init(); -  route_map_match_interface_hook (generic_match_add); -  route_map_no_match_interface_hook (generic_match_delete); +	route_map_match_interface_hook(generic_match_add); +	route_map_no_match_interface_hook(generic_match_delete); -  route_map_match_metric_hook (generic_match_add); -  route_map_no_match_metric_hook (generic_match_delete); +	route_map_match_metric_hook(generic_match_add); +	route_map_no_match_metric_hook(generic_match_delete); -  route_map_match_tag_hook (generic_match_add); -  route_map_no_match_tag_hook (generic_match_delete); +	route_map_match_tag_hook(generic_match_add); +	route_map_no_match_tag_hook(generic_match_delete); -  route_map_set_ipv6_nexthop_local_hook (generic_set_add); -  route_map_no_set_ipv6_nexthop_local_hook (generic_set_delete); +	route_map_set_ipv6_nexthop_local_hook(generic_set_add); +	route_map_no_set_ipv6_nexthop_local_hook(generic_set_delete); -  route_map_set_metric_hook (generic_set_add); -  route_map_no_set_metric_hook (generic_set_delete); +	route_map_set_metric_hook(generic_set_add); +	route_map_no_set_metric_hook(generic_set_delete); -  route_map_set_tag_hook (generic_set_add); -  route_map_no_set_tag_hook (generic_set_delete); +	route_map_set_tag_hook(generic_set_add); +	route_map_no_set_tag_hook(generic_set_delete); -  route_map_install_match (&route_match_metric_cmd); -  route_map_install_match (&route_match_interface_cmd); -  route_map_install_match (&route_match_tag_cmd); -  route_map_install_set (&route_set_metric_cmd); -  route_map_install_set (&route_set_ipv6_nexthop_local_cmd); -  route_map_install_set (&route_set_tag_cmd); +	route_map_install_match(&route_match_metric_cmd); +	route_map_install_match(&route_match_interface_cmd); +	route_map_install_match(&route_match_tag_cmd); +	route_map_install_set(&route_set_metric_cmd); +	route_map_install_set(&route_set_ipv6_nexthop_local_cmd); +	route_map_install_set(&route_set_tag_cmd);  } diff --git a/ripngd/ripng_zebra.c b/ripngd/ripng_zebra.c index b49de9902e..386bee43b8 100644 --- a/ripngd/ripng_zebra.c +++ b/ripngd/ripng_zebra.c @@ -37,270 +37,261 @@  struct zclient *zclient = NULL;  /* Send ECMP routes to zebra. */ -static void -ripng_zebra_ipv6_send (struct route_node *rp, u_char cmd) +static void ripng_zebra_ipv6_send(struct route_node *rp, u_char cmd)  { -  static struct in6_addr **nexthops = NULL; -  static ifindex_t *ifindexes = NULL; -  static unsigned int nexthops_len = 0; - -  struct list *list = (struct list *)rp->info; -  struct zapi_ipv6 api; -  struct listnode *listnode = NULL; -  struct ripng_info *rinfo = NULL; -  int count = 0; - -  if (vrf_bitmap_check (zclient->redist[AFI_IP6][ZEBRA_ROUTE_RIPNG], VRF_DEFAULT)) -    { -      api.vrf_id = VRF_DEFAULT; -      api.type = ZEBRA_ROUTE_RIPNG; -      api.instance = 0; -      api.flags = 0; -      api.message = 0; -      api.safi = SAFI_UNICAST; - -      if (nexthops_len < listcount (list)) -        { -          nexthops_len = listcount (list); -          nexthops = XREALLOC (MTYPE_TMP, nexthops, -                               nexthops_len * sizeof (struct in6_addr *)); -          ifindexes = XREALLOC (MTYPE_TMP, ifindexes, -                                nexthops_len * sizeof (unsigned int)); -        } - -      SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP); -      SET_FLAG (api.message, ZAPI_MESSAGE_IFINDEX); -      for (ALL_LIST_ELEMENTS_RO (list, listnode, rinfo)) -        { -          nexthops[count] = &rinfo->nexthop; -          ifindexes[count] = rinfo->ifindex; -          count++; -          if (cmd == ZEBRA_IPV6_ROUTE_ADD) -            SET_FLAG (rinfo->flags, RIPNG_RTF_FIB); -          else -            UNSET_FLAG (rinfo->flags, RIPNG_RTF_FIB); -        } - -      api.nexthop = nexthops; -      api.nexthop_num = count; -      api.ifindex = ifindexes; -      api.ifindex_num = count; - -      rinfo = listgetdata (listhead (list)); - -      SET_FLAG (api.message, ZAPI_MESSAGE_METRIC); -      api.metric = rinfo->metric; - -      if (rinfo->tag) -        { -          SET_FLAG (api.message, ZAPI_MESSAGE_TAG); -          api.tag = rinfo->tag; -        } - -      zapi_ipv6_route (cmd, zclient, -                       (struct prefix_ipv6 *)&rp->p, NULL, &api); - -      if (IS_RIPNG_DEBUG_ZEBRA) -        { -          if (ripng->ecmp) -            zlog_debug ("%s: %s/%d nexthops %d", -                        (cmd == ZEBRA_IPV6_ROUTE_ADD) ? \ -                            "Install into zebra" : "Delete from zebra", -                        inet6_ntoa (rp->p.u.prefix6), rp->p.prefixlen, count); -          else -            zlog_debug ("%s: %s/%d", -                        (cmd == ZEBRA_IPV6_ROUTE_ADD) ? \ -                            "Install into zebra" : "Delete from zebra", -                        inet6_ntoa (rp->p.u.prefix6), rp->p.prefixlen); -        } -    } +	static struct in6_addr **nexthops = NULL; +	static ifindex_t *ifindexes = NULL; +	static unsigned int nexthops_len = 0; + +	struct list *list = (struct list *)rp->info; +	struct zapi_ipv6 api; +	struct listnode *listnode = NULL; +	struct ripng_info *rinfo = NULL; +	int count = 0; + +	if (vrf_bitmap_check(zclient->redist[AFI_IP6][ZEBRA_ROUTE_RIPNG], +			     VRF_DEFAULT)) { +		api.vrf_id = VRF_DEFAULT; +		api.type = ZEBRA_ROUTE_RIPNG; +		api.instance = 0; +		api.flags = 0; +		api.message = 0; +		api.safi = SAFI_UNICAST; + +		if (nexthops_len < listcount(list)) { +			nexthops_len = listcount(list); +			nexthops = XREALLOC( +				MTYPE_TMP, nexthops, +				nexthops_len * sizeof(struct in6_addr *)); +			ifindexes = +				XREALLOC(MTYPE_TMP, ifindexes, +					 nexthops_len * sizeof(unsigned int)); +		} + +		SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP); +		SET_FLAG(api.message, ZAPI_MESSAGE_IFINDEX); +		for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) { +			nexthops[count] = &rinfo->nexthop; +			ifindexes[count] = rinfo->ifindex; +			count++; +			if (cmd == ZEBRA_IPV6_ROUTE_ADD) +				SET_FLAG(rinfo->flags, RIPNG_RTF_FIB); +			else +				UNSET_FLAG(rinfo->flags, RIPNG_RTF_FIB); +		} + +		api.nexthop = nexthops; +		api.nexthop_num = count; +		api.ifindex = ifindexes; +		api.ifindex_num = count; + +		rinfo = listgetdata(listhead(list)); + +		SET_FLAG(api.message, ZAPI_MESSAGE_METRIC); +		api.metric = rinfo->metric; + +		if (rinfo->tag) { +			SET_FLAG(api.message, ZAPI_MESSAGE_TAG); +			api.tag = rinfo->tag; +		} + +		zapi_ipv6_route(cmd, zclient, (struct prefix_ipv6 *)&rp->p, +				NULL, &api); + +		if (IS_RIPNG_DEBUG_ZEBRA) { +			if (ripng->ecmp) +				zlog_debug("%s: %s/%d nexthops %d", +					   (cmd == ZEBRA_IPV6_ROUTE_ADD) +						   ? "Install into zebra" +						   : "Delete from zebra", +					   inet6_ntoa(rp->p.u.prefix6), +					   rp->p.prefixlen, count); +			else +				zlog_debug("%s: %s/%d", +					   (cmd == ZEBRA_IPV6_ROUTE_ADD) +						   ? "Install into zebra" +						   : "Delete from zebra", +					   inet6_ntoa(rp->p.u.prefix6), +					   rp->p.prefixlen); +		} +	}  }  /* Add/update ECMP routes to zebra. */ -void -ripng_zebra_ipv6_add (struct route_node *rp) +void ripng_zebra_ipv6_add(struct route_node *rp)  { -  ripng_zebra_ipv6_send (rp, ZEBRA_IPV6_ROUTE_ADD); +	ripng_zebra_ipv6_send(rp, ZEBRA_IPV6_ROUTE_ADD);  }  /* Delete ECMP routes from zebra. */ -void -ripng_zebra_ipv6_delete (struct route_node *rp) +void ripng_zebra_ipv6_delete(struct route_node *rp)  { -  ripng_zebra_ipv6_send (rp, ZEBRA_IPV6_ROUTE_DELETE); +	ripng_zebra_ipv6_send(rp, ZEBRA_IPV6_ROUTE_DELETE);  }  /* Zebra route add and delete treatment. */ -static int -ripng_zebra_read_ipv6 (int command, struct zclient *zclient, -		       zebra_size_t length, vrf_id_t vrf_id) +static int ripng_zebra_read_ipv6(int command, struct zclient *zclient, +				 zebra_size_t length, vrf_id_t vrf_id)  { -  struct stream *s; -  struct zapi_ipv6 api; -  unsigned long ifindex; -  struct in6_addr nexthop; -  struct prefix_ipv6 p, src_p; - -  s = zclient->ibuf; -  ifindex = 0; -  memset (&nexthop, 0, sizeof (struct in6_addr)); - -  /* Type, flags, message. */ -  api.type = stream_getc (s); -  api.instance = stream_getw (s); -  api.flags = stream_getl (s); -  api.message = stream_getc (s); - -  /* IPv6 prefix. */ -  memset (&p, 0, sizeof (struct prefix_ipv6)); -  p.family = AF_INET6; -  p.prefixlen = MIN(IPV6_MAX_PREFIXLEN, stream_getc (s)); -  stream_get (&p.prefix, s, PSIZE (p.prefixlen)); - -  memset (&src_p, 0, sizeof (struct prefix_ipv6)); -  src_p.family = AF_INET6; -  if (CHECK_FLAG (api.message, ZAPI_MESSAGE_SRCPFX)) -    { -      src_p.prefixlen = stream_getc (s); -      stream_get (&src_p.prefix, s, PSIZE (src_p.prefixlen)); -    } - -  if (src_p.prefixlen) -    /* we completely ignore srcdest routes for now. */ -    return 0; - -  /* Nexthop, ifindex, distance, metric. */ -  if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP)) -    { -      api.nexthop_num = stream_getc (s); -      stream_get (&nexthop, s, 16); -    } -  if (CHECK_FLAG (api.message, ZAPI_MESSAGE_IFINDEX)) -    { -      api.ifindex_num = stream_getc (s); -      ifindex = stream_getl (s); -    } -  if (CHECK_FLAG (api.message, ZAPI_MESSAGE_DISTANCE)) -    api.distance = stream_getc (s); -  else -    api.distance = 0; -  if (CHECK_FLAG (api.message, ZAPI_MESSAGE_METRIC)) -    api.metric = stream_getl (s); -  else -    api.metric = 0; - -  if (CHECK_FLAG (api.message, ZAPI_MESSAGE_TAG)) -    api.tag = stream_getl (s); -  else -    api.tag = 0; - -  if (command == ZEBRA_REDISTRIBUTE_IPV6_ADD) -    ripng_redistribute_add (api.type, RIPNG_ROUTE_REDISTRIBUTE, &p, ifindex, &nexthop, api.tag); -  else -    ripng_redistribute_delete (api.type, RIPNG_ROUTE_REDISTRIBUTE, &p, ifindex); - -  return 0; +	struct stream *s; +	struct zapi_ipv6 api; +	unsigned long ifindex; +	struct in6_addr nexthop; +	struct prefix_ipv6 p, src_p; + +	s = zclient->ibuf; +	ifindex = 0; +	memset(&nexthop, 0, sizeof(struct in6_addr)); + +	/* Type, flags, message. */ +	api.type = stream_getc(s); +	api.instance = stream_getw(s); +	api.flags = stream_getl(s); +	api.message = stream_getc(s); + +	/* IPv6 prefix. */ +	memset(&p, 0, sizeof(struct prefix_ipv6)); +	p.family = AF_INET6; +	p.prefixlen = MIN(IPV6_MAX_PREFIXLEN, stream_getc(s)); +	stream_get(&p.prefix, s, PSIZE(p.prefixlen)); + +	memset(&src_p, 0, sizeof(struct prefix_ipv6)); +	src_p.family = AF_INET6; +	if (CHECK_FLAG(api.message, ZAPI_MESSAGE_SRCPFX)) { +		src_p.prefixlen = stream_getc(s); +		stream_get(&src_p.prefix, s, PSIZE(src_p.prefixlen)); +	} + +	if (src_p.prefixlen) +		/* we completely ignore srcdest routes for now. */ +		return 0; + +	/* Nexthop, ifindex, distance, metric. */ +	if (CHECK_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP)) { +		api.nexthop_num = stream_getc(s); +		stream_get(&nexthop, s, 16); +	} +	if (CHECK_FLAG(api.message, ZAPI_MESSAGE_IFINDEX)) { +		api.ifindex_num = stream_getc(s); +		ifindex = stream_getl(s); +	} +	if (CHECK_FLAG(api.message, ZAPI_MESSAGE_DISTANCE)) +		api.distance = stream_getc(s); +	else +		api.distance = 0; +	if (CHECK_FLAG(api.message, ZAPI_MESSAGE_METRIC)) +		api.metric = stream_getl(s); +	else +		api.metric = 0; + +	if (CHECK_FLAG(api.message, ZAPI_MESSAGE_TAG)) +		api.tag = stream_getl(s); +	else +		api.tag = 0; + +	if (command == ZEBRA_REDISTRIBUTE_IPV6_ADD) +		ripng_redistribute_add(api.type, RIPNG_ROUTE_REDISTRIBUTE, &p, +				       ifindex, &nexthop, api.tag); +	else +		ripng_redistribute_delete(api.type, RIPNG_ROUTE_REDISTRIBUTE, +					  &p, ifindex); + +	return 0;  } -void -ripng_zclient_reset (void) +void ripng_zclient_reset(void)  { -  zclient_reset (zclient); +	zclient_reset(zclient);  } -static int -ripng_redistribute_unset (int type) +static int ripng_redistribute_unset(int type)  { -  if (! vrf_bitmap_check (zclient->redist[AFI_IP6][type], VRF_DEFAULT)) -    return CMD_SUCCESS; +	if (!vrf_bitmap_check(zclient->redist[AFI_IP6][type], VRF_DEFAULT)) +		return CMD_SUCCESS; + +	vrf_bitmap_set(zclient->redist[AFI_IP6][type], VRF_DEFAULT); -  vrf_bitmap_set (zclient->redist[AFI_IP6][type], VRF_DEFAULT); +	if (zclient->sock > 0) +		zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, zclient, +					AFI_IP6, type, 0, VRF_DEFAULT); -  if (zclient->sock > 0) -    zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP6, type, 0, VRF_DEFAULT); +	ripng_redistribute_withdraw(type); -  ripng_redistribute_withdraw (type); -   -  return CMD_SUCCESS; +	return CMD_SUCCESS;  } -int -ripng_redistribute_check (int type) +int ripng_redistribute_check(int type)  { -  return vrf_bitmap_check (zclient->redist[AFI_IP6][type], VRF_DEFAULT); +	return vrf_bitmap_check(zclient->redist[AFI_IP6][type], VRF_DEFAULT);  } -static void -ripng_redistribute_metric_set (int type, int metric) +static void ripng_redistribute_metric_set(int type, int metric)  { -  ripng->route_map[type].metric_config = 1; -  ripng->route_map[type].metric = metric; +	ripng->route_map[type].metric_config = 1; +	ripng->route_map[type].metric = metric;  } -static int -ripng_redistribute_metric_unset (int type) +static int ripng_redistribute_metric_unset(int type)  { -  ripng->route_map[type].metric_config = 0; -  ripng->route_map[type].metric = 0; -  return 0; +	ripng->route_map[type].metric_config = 0; +	ripng->route_map[type].metric = 0; +	return 0;  } -static void -ripng_redistribute_routemap_set (int type, const char *name) +static void ripng_redistribute_routemap_set(int type, const char *name)  { -  if (ripng->route_map[type].name) -    free (ripng->route_map[type].name); +	if (ripng->route_map[type].name) +		free(ripng->route_map[type].name); -  ripng->route_map[type].name = strdup (name); -  ripng->route_map[type].map = route_map_lookup_by_name (name); +	ripng->route_map[type].name = strdup(name); +	ripng->route_map[type].map = route_map_lookup_by_name(name);  } -static void -ripng_redistribute_routemap_unset (int type) +static void ripng_redistribute_routemap_unset(int type)  { -  if (ripng->route_map[type].name) -    free (ripng->route_map[type].name); +	if (ripng->route_map[type].name) +		free(ripng->route_map[type].name); -  ripng->route_map[type].name = NULL; -  ripng->route_map[type].map = NULL; +	ripng->route_map[type].name = NULL; +	ripng->route_map[type].map = NULL;  }  /* Redistribution types */  static struct { -  int type; -  int str_min_len; -  const char *str; -} redist_type[] = { -  {ZEBRA_ROUTE_KERNEL,  1, "kernel"}, -  {ZEBRA_ROUTE_CONNECT, 1, "connected"}, -  {ZEBRA_ROUTE_STATIC,  1, "static"}, -  {ZEBRA_ROUTE_OSPF6,   1, "ospf6"}, -  {ZEBRA_ROUTE_BGP,     2, "bgp"}, -  {ZEBRA_ROUTE_VNC,     1, "vnc"}, -  {0, 0, NULL} -}; - -void -ripng_redistribute_clean () +	int type; +	int str_min_len; +	const char *str; +} redist_type[] = {{ZEBRA_ROUTE_KERNEL, 1, "kernel"}, +		   {ZEBRA_ROUTE_CONNECT, 1, "connected"}, +		   {ZEBRA_ROUTE_STATIC, 1, "static"}, +		   {ZEBRA_ROUTE_OSPF6, 1, "ospf6"}, +		   {ZEBRA_ROUTE_BGP, 2, "bgp"}, +		   {ZEBRA_ROUTE_VNC, 1, "vnc"}, +		   {0, 0, NULL}}; + +void ripng_redistribute_clean()  { -  int i; - -  for (i = 0; redist_type[i].str; i++) -    { -      if (vrf_bitmap_check (zclient->redist[AFI_IP6][redist_type[i].type], VRF_DEFAULT)) -        { -          if (zclient->sock > 0) -            zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, -                                     zclient, AFI_IP6, redist_type[i].type, 0, -                                     VRF_DEFAULT); - -          vrf_bitmap_unset (zclient->redist[AFI_IP6][redist_type[i].type], VRF_DEFAULT); - -          /* Remove the routes from RIPng table. */ -          ripng_redistribute_withdraw (redist_type[i].type); -        } -    } +	int i; + +	for (i = 0; redist_type[i].str; i++) { +		if (vrf_bitmap_check( +			    zclient->redist[AFI_IP6][redist_type[i].type], +			    VRF_DEFAULT)) { +			if (zclient->sock > 0) +				zebra_redistribute_send( +					ZEBRA_REDISTRIBUTE_DELETE, zclient, +					AFI_IP6, redist_type[i].type, 0, +					VRF_DEFAULT); + +			vrf_bitmap_unset( +				zclient->redist[AFI_IP6][redist_type[i].type], +				VRF_DEFAULT); + +			/* Remove the routes from RIPng table. */ +			ripng_redistribute_withdraw(redist_type[i].type); +		} +	}  }  DEFUN (ripng_redistribute_ripng, @@ -309,8 +300,9 @@ DEFUN (ripng_redistribute_ripng,         "Redistribute information from another routing protocol\n"         "RIPng route\n")  { -  vrf_bitmap_set (zclient->redist[AFI_IP6][ZEBRA_ROUTE_RIPNG], VRF_DEFAULT); -  return CMD_SUCCESS; +	vrf_bitmap_set(zclient->redist[AFI_IP6][ZEBRA_ROUTE_RIPNG], +		       VRF_DEFAULT); +	return CMD_SUCCESS;  }  DEFUN (no_ripng_redistribute_ripng, @@ -320,8 +312,9 @@ DEFUN (no_ripng_redistribute_ripng,         "Redistribute information from another routing protocol\n"         "RIPng route\n")  { -  vrf_bitmap_unset (zclient->redist[AFI_IP6][ZEBRA_ROUTE_RIPNG], VRF_DEFAULT); -  return CMD_SUCCESS; +	vrf_bitmap_unset(zclient->redist[AFI_IP6][ZEBRA_ROUTE_RIPNG], +			 VRF_DEFAULT); +	return CMD_SUCCESS;  }  DEFUN (ripng_redistribute_type, @@ -330,19 +323,19 @@ DEFUN (ripng_redistribute_type,         "Redistribute\n"         FRR_REDIST_HELP_STR_RIPNGD)  { -  int type; +	int type; -  char *proto = argv[argc - 1]->text; -  type = proto_redistnum(AFI_IP6, proto); +	char *proto = argv[argc - 1]->text; +	type = proto_redistnum(AFI_IP6, proto); -  if (type < 0) -    { -      vty_out (vty, "Invalid type %s\n", proto); -      return CMD_WARNING_CONFIG_FAILED; -    } +	if (type < 0) { +		vty_out(vty, "Invalid type %s\n", proto); +		return CMD_WARNING_CONFIG_FAILED; +	} -  zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0, VRF_DEFAULT); -  return CMD_SUCCESS; +	zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0, +			     VRF_DEFAULT); +	return CMD_SUCCESS;  }  DEFUN (no_ripng_redistribute_type, @@ -356,20 +349,19 @@ DEFUN (no_ripng_redistribute_type,         "Route map reference\n"         "Pointer to route-map entries\n")  { -  int type; +	int type; -  char *proto = argv[2]->text; -  type = proto_redistnum(AFI_IP6, proto); +	char *proto = argv[2]->text; +	type = proto_redistnum(AFI_IP6, proto); -  if (type < 0) -    { -      vty_out (vty, "Invalid type %s\n", proto); -      return CMD_WARNING_CONFIG_FAILED; -    } +	if (type < 0) { +		vty_out(vty, "Invalid type %s\n", proto); +		return CMD_WARNING_CONFIG_FAILED; +	} -  ripng_redistribute_metric_unset (type); -  ripng_redistribute_routemap_unset (type); -  return ripng_redistribute_unset (type); +	ripng_redistribute_metric_unset(type); +	ripng_redistribute_routemap_unset(type); +	return ripng_redistribute_unset(type);  } @@ -381,24 +373,23 @@ DEFUN (ripng_redistribute_type_metric,         "Metric\n"         "Metric value\n")  { -  int idx_protocol = 1; -  int idx_number = 3; -  int type; -  int metric; - -  metric = atoi (argv[idx_number]->arg); -  type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); - -  if (type < 0) -    { -      vty_out (vty, "Invalid type %s\n", argv[idx_protocol]->text); -      return CMD_WARNING_CONFIG_FAILED; -    } - -  ripng_redistribute_metric_set (type, metric); -  zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0, -                        VRF_DEFAULT); -  return CMD_SUCCESS; +	int idx_protocol = 1; +	int idx_number = 3; +	int type; +	int metric; + +	metric = atoi(argv[idx_number]->arg); +	type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); + +	if (type < 0) { +		vty_out(vty, "Invalid type %s\n", argv[idx_protocol]->text); +		return CMD_WARNING_CONFIG_FAILED; +	} + +	ripng_redistribute_metric_set(type, metric); +	zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0, +			     VRF_DEFAULT); +	return CMD_SUCCESS;  }  DEFUN (ripng_redistribute_type_routemap, @@ -409,22 +400,21 @@ DEFUN (ripng_redistribute_type_routemap,         "Route map reference\n"         "Pointer to route-map entries\n")  { -  int idx_protocol = 1; -  int idx_word = 3; -  int type; - -  type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); - -  if (type < 0) -    { -      vty_out (vty, "Invalid type %s\n", argv[idx_protocol]->text); -      return CMD_WARNING_CONFIG_FAILED; -    } - -  ripng_redistribute_routemap_set (type, argv[idx_word]->text); -  zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0, -                        VRF_DEFAULT); - return CMD_SUCCESS; +	int idx_protocol = 1; +	int idx_word = 3; +	int type; + +	type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); + +	if (type < 0) { +		vty_out(vty, "Invalid type %s\n", argv[idx_protocol]->text); +		return CMD_WARNING_CONFIG_FAILED; +	} + +	ripng_redistribute_routemap_set(type, argv[idx_word]->text); +	zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0, +			     VRF_DEFAULT); +	return CMD_SUCCESS;  }  DEFUN (ripng_redistribute_type_metric_routemap, @@ -437,130 +427,130 @@ DEFUN (ripng_redistribute_type_metric_routemap,         "Route map reference\n"         "Pointer to route-map entries\n")  { -  int idx_protocol = 1; -  int idx_number = 3; -  int idx_word = 5; -  int type; -  int metric; - -  type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); -  metric = atoi (argv[idx_number]->arg); - -  if (type < 0) -    { -      vty_out (vty, "Invalid type %s\n", argv[idx_protocol]->text); -      return CMD_WARNING_CONFIG_FAILED; -    } - -  ripng_redistribute_metric_set (type, metric); -  ripng_redistribute_routemap_set (type, argv[idx_word]->text); -  zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0, VRF_DEFAULT); -  return CMD_SUCCESS; +	int idx_protocol = 1; +	int idx_number = 3; +	int idx_word = 5; +	int type; +	int metric; + +	type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); +	metric = atoi(argv[idx_number]->arg); + +	if (type < 0) { +		vty_out(vty, "Invalid type %s\n", argv[idx_protocol]->text); +		return CMD_WARNING_CONFIG_FAILED; +	} + +	ripng_redistribute_metric_set(type, metric); +	ripng_redistribute_routemap_set(type, argv[idx_word]->text); +	zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0, +			     VRF_DEFAULT); +	return CMD_SUCCESS;  } -void -ripng_redistribute_write (struct vty *vty, int config_mode) +void ripng_redistribute_write(struct vty *vty, int config_mode)  { -  int i; - -  for (i = 0; i < ZEBRA_ROUTE_MAX; i++) -    if (i != zclient->redist_default && -        vrf_bitmap_check (zclient->redist[AFI_IP6][i], VRF_DEFAULT)) -      { -      if (config_mode) -	{ -	  if (ripng->route_map[i].metric_config) -	    { -	      if (ripng->route_map[i].name) -		vty_out (vty, " redistribute %s metric %d route-map %s\n", -			 zebra_route_string(i), ripng->route_map[i].metric, -			ripng->route_map[i].name); -	      else -		vty_out (vty, " redistribute %s metric %d\n", -			zebra_route_string(i),ripng->route_map[i].metric); -	    } -	  else -	    { -	      if (ripng->route_map[i].name) -		vty_out (vty, " redistribute %s route-map %s\n", -			 zebra_route_string(i),ripng->route_map[i].name); -	      else -		vty_out (vty, " redistribute %s\n",zebra_route_string(i)); -	    } -	} -      else -	vty_out (vty, "    %s", zebra_route_string(i)); -      } +	int i; + +	for (i = 0; i < ZEBRA_ROUTE_MAX; i++) +		if (i != zclient->redist_default +		    && vrf_bitmap_check(zclient->redist[AFI_IP6][i], +					VRF_DEFAULT)) { +			if (config_mode) { +				if (ripng->route_map[i].metric_config) { +					if (ripng->route_map[i].name) +						vty_out(vty, +							" redistribute %s metric %d route-map %s\n", +							zebra_route_string(i), +							ripng->route_map[i] +								.metric, +							ripng->route_map[i] +								.name); +					else +						vty_out(vty, +							" redistribute %s metric %d\n", +							zebra_route_string(i), +							ripng->route_map[i] +								.metric); +				} else { +					if (ripng->route_map[i].name) +						vty_out(vty, +							" redistribute %s route-map %s\n", +							zebra_route_string(i), +							ripng->route_map[i] +								.name); +					else +						vty_out(vty, +							" redistribute %s\n", +							zebra_route_string(i)); +				} +			} else +				vty_out(vty, "    %s", zebra_route_string(i)); +		}  }  /* RIPng configuration write function. */ -static int -zebra_config_write (struct vty *vty) +static int zebra_config_write(struct vty *vty)  { -  if (! zclient->enable) -    { -      vty_out (vty, "no router zebra\n"); -      return 1; -    } -  else if (! vrf_bitmap_check (zclient->redist[AFI_IP6][ZEBRA_ROUTE_RIPNG], VRF_DEFAULT)) -    { -      vty_out (vty, "router zebra\n"); -      vty_out (vty, " no redistribute ripng\n"); -      return 1; -    } -  return 0; +	if (!zclient->enable) { +		vty_out(vty, "no router zebra\n"); +		return 1; +	} else if (!vrf_bitmap_check( +			   zclient->redist[AFI_IP6][ZEBRA_ROUTE_RIPNG], +			   VRF_DEFAULT)) { +		vty_out(vty, "router zebra\n"); +		vty_out(vty, " no redistribute ripng\n"); +		return 1; +	} +	return 0;  }  /* Zebra node structure. */ -static struct cmd_node zebra_node = -{ -  ZEBRA_NODE, -  "%s(config-router)# ", +static struct cmd_node zebra_node = { +	ZEBRA_NODE, "%s(config-router)# ",  }; -static void -ripng_zebra_connected (struct zclient *zclient) +static void ripng_zebra_connected(struct zclient *zclient)  { -  zclient_send_reg_requests (zclient, VRF_DEFAULT); +	zclient_send_reg_requests(zclient, VRF_DEFAULT);  }  /* Initialize zebra structure and it's commands. */ -void -zebra_init (struct thread_master *master) +void zebra_init(struct thread_master *master)  { -  /* Allocate zebra structure. */ -  zclient = zclient_new(master); -  zclient_init (zclient, ZEBRA_ROUTE_RIPNG, 0); - -  zclient->zebra_connected = ripng_zebra_connected; -  zclient->interface_up = ripng_interface_up; -  zclient->interface_down = ripng_interface_down; -  zclient->interface_add = ripng_interface_add; -  zclient->interface_delete = ripng_interface_delete; -  zclient->interface_address_add = ripng_interface_address_add; -  zclient->interface_address_delete = ripng_interface_address_delete; -  zclient->redistribute_route_ipv6_add = ripng_zebra_read_ipv6; -  zclient->redistribute_route_ipv6_del = ripng_zebra_read_ipv6; -   -  /* Install zebra node. */ -  install_node (&zebra_node, zebra_config_write); - -  /* Install command element for zebra node. */  -  install_default (ZEBRA_NODE); -  install_element (ZEBRA_NODE, &ripng_redistribute_ripng_cmd); -  install_element (ZEBRA_NODE, &no_ripng_redistribute_ripng_cmd); - -  /* Install command elements to ripng node */ -  install_element (RIPNG_NODE, &ripng_redistribute_type_cmd); -  install_element (RIPNG_NODE, &ripng_redistribute_type_routemap_cmd); -  install_element (RIPNG_NODE, &ripng_redistribute_type_metric_cmd); -  install_element (RIPNG_NODE, &ripng_redistribute_type_metric_routemap_cmd); -  install_element (RIPNG_NODE, &no_ripng_redistribute_type_cmd); +	/* Allocate zebra structure. */ +	zclient = zclient_new(master); +	zclient_init(zclient, ZEBRA_ROUTE_RIPNG, 0); + +	zclient->zebra_connected = ripng_zebra_connected; +	zclient->interface_up = ripng_interface_up; +	zclient->interface_down = ripng_interface_down; +	zclient->interface_add = ripng_interface_add; +	zclient->interface_delete = ripng_interface_delete; +	zclient->interface_address_add = ripng_interface_address_add; +	zclient->interface_address_delete = ripng_interface_address_delete; +	zclient->redistribute_route_ipv6_add = ripng_zebra_read_ipv6; +	zclient->redistribute_route_ipv6_del = ripng_zebra_read_ipv6; + +	/* Install zebra node. */ +	install_node(&zebra_node, zebra_config_write); + +	/* Install command element for zebra node. */ +	install_default(ZEBRA_NODE); +	install_element(ZEBRA_NODE, &ripng_redistribute_ripng_cmd); +	install_element(ZEBRA_NODE, &no_ripng_redistribute_ripng_cmd); + +	/* Install command elements to ripng node */ +	install_element(RIPNG_NODE, &ripng_redistribute_type_cmd); +	install_element(RIPNG_NODE, &ripng_redistribute_type_routemap_cmd); +	install_element(RIPNG_NODE, &ripng_redistribute_type_metric_cmd); +	install_element(RIPNG_NODE, +			&ripng_redistribute_type_metric_routemap_cmd); +	install_element(RIPNG_NODE, &no_ripng_redistribute_type_cmd);  } -void -ripng_zebra_stop (void) +void ripng_zebra_stop(void)  { -  zclient_stop (zclient); -  zclient_free (zclient); +	zclient_stop(zclient); +	zclient_free(zclient);  } diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index 8b4c3e8507..2883698f47 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -46,493 +46,470 @@     ripng->fd must be negative value. */  struct ripng *ripng = NULL; -enum -{ -  ripng_all_route, -  ripng_changed_route, +enum { ripng_all_route, +       ripng_changed_route,  };  extern struct zebra_privs_t ripngd_privs;  /* Prototypes. */ -void -ripng_output_process (struct interface *, struct sockaddr_in6 *, int); +void ripng_output_process(struct interface *, struct sockaddr_in6 *, int); -int -ripng_triggered_update (struct thread *); +int ripng_triggered_update(struct thread *);  /* RIPng next hop specification. */ -struct ripng_nexthop -{ -  enum ripng_nexthop_type -  { -    RIPNG_NEXTHOP_UNSPEC, -    RIPNG_NEXTHOP_ADDRESS -  } flag; -  struct in6_addr address; +struct ripng_nexthop { +	enum ripng_nexthop_type { +		RIPNG_NEXTHOP_UNSPEC, +		RIPNG_NEXTHOP_ADDRESS +	} flag; +	struct in6_addr address;  }; -static int -ripng_route_rte (struct ripng_info *rinfo) +static int ripng_route_rte(struct ripng_info *rinfo)  { -  return (rinfo->type == ZEBRA_ROUTE_RIPNG && rinfo->sub_type == RIPNG_ROUTE_RTE); +	return (rinfo->type == ZEBRA_ROUTE_RIPNG +		&& rinfo->sub_type == RIPNG_ROUTE_RTE);  }  /* Allocate new ripng information. */ -struct ripng_info * -ripng_info_new () +struct ripng_info *ripng_info_new()  { -  struct ripng_info *new; +	struct ripng_info *new; -  new = XCALLOC (MTYPE_RIPNG_ROUTE, sizeof (struct ripng_info)); -  return new; +	new = XCALLOC(MTYPE_RIPNG_ROUTE, sizeof(struct ripng_info)); +	return new;  }  /* Free ripng information. */ -void -ripng_info_free (struct ripng_info *rinfo) +void ripng_info_free(struct ripng_info *rinfo)  { -  XFREE (MTYPE_RIPNG_ROUTE, rinfo); +	XFREE(MTYPE_RIPNG_ROUTE, rinfo);  }  /* Create ripng socket. */ -static int  -ripng_make_socket (void) +static int ripng_make_socket(void)  { -  int ret; -  int sock; -  struct sockaddr_in6 ripaddr; +	int ret; +	int sock; +	struct sockaddr_in6 ripaddr; -  sock = socket (AF_INET6, SOCK_DGRAM, 0); -  if (sock < 0) -    { -      zlog_err("Can't make ripng socket"); -      return sock; -    } +	sock = socket(AF_INET6, SOCK_DGRAM, 0); +	if (sock < 0) { +		zlog_err("Can't make ripng socket"); +		return sock; +	} -  setsockopt_so_recvbuf (sock, 8096); -  ret = setsockopt_ipv6_pktinfo (sock, 1); -  if (ret < 0) -    return ret; +	setsockopt_so_recvbuf(sock, 8096); +	ret = setsockopt_ipv6_pktinfo(sock, 1); +	if (ret < 0) +		return ret;  #ifdef IPTOS_PREC_INTERNETCONTROL -  ret = setsockopt_ipv6_tclass (sock, IPTOS_PREC_INTERNETCONTROL); -  if (ret < 0) -    return ret; +	ret = setsockopt_ipv6_tclass(sock, IPTOS_PREC_INTERNETCONTROL); +	if (ret < 0) +		return ret;  #endif -  ret = setsockopt_ipv6_multicast_hops (sock, 255); -  if (ret < 0) -    return ret; -  ret = setsockopt_ipv6_multicast_loop (sock, 0); -  if (ret < 0) -    return ret; -  ret = setsockopt_ipv6_hoplimit (sock, 1); -  if (ret < 0) -    return ret; - -  memset (&ripaddr, 0, sizeof (ripaddr)); -  ripaddr.sin6_family = AF_INET6; +	ret = setsockopt_ipv6_multicast_hops(sock, 255); +	if (ret < 0) +		return ret; +	ret = setsockopt_ipv6_multicast_loop(sock, 0); +	if (ret < 0) +		return ret; +	ret = setsockopt_ipv6_hoplimit(sock, 1); +	if (ret < 0) +		return ret; + +	memset(&ripaddr, 0, sizeof(ripaddr)); +	ripaddr.sin6_family = AF_INET6;  #ifdef SIN6_LEN -  ripaddr.sin6_len = sizeof (struct sockaddr_in6); +	ripaddr.sin6_len = sizeof(struct sockaddr_in6);  #endif /* SIN6_LEN */ -  ripaddr.sin6_port = htons (RIPNG_PORT_DEFAULT); +	ripaddr.sin6_port = htons(RIPNG_PORT_DEFAULT); -  if (ripngd_privs.change (ZPRIVS_RAISE)) -    zlog_err ("ripng_make_socket: could not raise privs"); -   -  ret = bind (sock, (struct sockaddr *) &ripaddr, sizeof (ripaddr)); -  if (ret < 0) -  { -    zlog_err("Can't bind ripng socket: %s.", safe_strerror(errno)); -    if (ripngd_privs.change (ZPRIVS_LOWER)) -      zlog_err ("ripng_make_socket: could not lower privs"); -    return ret; -  } -  if (ripngd_privs.change (ZPRIVS_LOWER)) -    zlog_err ("ripng_make_socket: could not lower privs"); -  return sock; +	if (ripngd_privs.change(ZPRIVS_RAISE)) +		zlog_err("ripng_make_socket: could not raise privs"); + +	ret = bind(sock, (struct sockaddr *)&ripaddr, sizeof(ripaddr)); +	if (ret < 0) { +		zlog_err("Can't bind ripng socket: %s.", safe_strerror(errno)); +		if (ripngd_privs.change(ZPRIVS_LOWER)) +			zlog_err("ripng_make_socket: could not lower privs"); +		return ret; +	} +	if (ripngd_privs.change(ZPRIVS_LOWER)) +		zlog_err("ripng_make_socket: could not lower privs"); +	return sock;  }  /* Send RIPng packet. */ -int -ripng_send_packet (caddr_t buf, int bufsize, struct sockaddr_in6 *to,  -		   struct interface *ifp) -{ -  int ret; -  struct msghdr msg; -  struct iovec iov; -  struct cmsghdr  *cmsgptr; -  char adata [256]; -  struct in6_pktinfo *pkt; -  struct sockaddr_in6 addr; - -  if (IS_RIPNG_DEBUG_SEND) { -    if (to) -      zlog_debug ("send to %s", inet6_ntoa (to->sin6_addr)); -    zlog_debug ("  send interface %s", ifp->name); -    zlog_debug ("  send packet size %d", bufsize); -  } - -  memset (&addr, 0, sizeof (struct sockaddr_in6)); -  addr.sin6_family = AF_INET6; +int ripng_send_packet(caddr_t buf, int bufsize, struct sockaddr_in6 *to, +		      struct interface *ifp) +{ +	int ret; +	struct msghdr msg; +	struct iovec iov; +	struct cmsghdr *cmsgptr; +	char adata[256]; +	struct in6_pktinfo *pkt; +	struct sockaddr_in6 addr; + +	if (IS_RIPNG_DEBUG_SEND) { +		if (to) +			zlog_debug("send to %s", inet6_ntoa(to->sin6_addr)); +		zlog_debug("  send interface %s", ifp->name); +		zlog_debug("  send packet size %d", bufsize); +	} + +	memset(&addr, 0, sizeof(struct sockaddr_in6)); +	addr.sin6_family = AF_INET6;  #ifdef SIN6_LEN -  addr.sin6_len = sizeof (struct sockaddr_in6); +	addr.sin6_len = sizeof(struct sockaddr_in6);  #endif /* SIN6_LEN */ -  addr.sin6_flowinfo = htonl (RIPNG_PRIORITY_DEFAULT); - -  /* When destination is specified. */ -  if (to != NULL) -    { -      addr.sin6_addr = to->sin6_addr; -      addr.sin6_port = to->sin6_port; -    } -  else -    { -      inet_pton(AF_INET6, RIPNG_GROUP, &addr.sin6_addr); -      addr.sin6_port = htons (RIPNG_PORT_DEFAULT); -    } - -  msg.msg_name = (void *) &addr; -  msg.msg_namelen = sizeof (struct sockaddr_in6); -  msg.msg_iov = &iov; -  msg.msg_iovlen = 1; -  msg.msg_control = (void *) adata; -  msg.msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo)); - -  iov.iov_base = buf; -  iov.iov_len = bufsize; - -  cmsgptr = (struct cmsghdr *)adata; -  cmsgptr->cmsg_len = CMSG_LEN(sizeof (struct in6_pktinfo)); -  cmsgptr->cmsg_level = IPPROTO_IPV6; -  cmsgptr->cmsg_type = IPV6_PKTINFO; - -  pkt = (struct in6_pktinfo *) CMSG_DATA (cmsgptr); -  memset (&pkt->ipi6_addr, 0, sizeof (struct in6_addr)); -  pkt->ipi6_ifindex = ifp->ifindex; - -  ret = sendmsg (ripng->sock, &msg, 0); +	addr.sin6_flowinfo = htonl(RIPNG_PRIORITY_DEFAULT); + +	/* When destination is specified. */ +	if (to != NULL) { +		addr.sin6_addr = to->sin6_addr; +		addr.sin6_port = to->sin6_port; +	} else { +		inet_pton(AF_INET6, RIPNG_GROUP, &addr.sin6_addr); +		addr.sin6_port = htons(RIPNG_PORT_DEFAULT); +	} -  if (ret < 0) { -    if (to) -      zlog_err ("RIPng send fail on %s to %s: %s", ifp->name,  -                inet6_ntoa (to->sin6_addr), safe_strerror (errno)); -    else -      zlog_err ("RIPng send fail on %s: %s", ifp->name, safe_strerror (errno)); -  } +	msg.msg_name = (void *)&addr; +	msg.msg_namelen = sizeof(struct sockaddr_in6); +	msg.msg_iov = &iov; +	msg.msg_iovlen = 1; +	msg.msg_control = (void *)adata; +	msg.msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo)); + +	iov.iov_base = buf; +	iov.iov_len = bufsize; + +	cmsgptr = (struct cmsghdr *)adata; +	cmsgptr->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo)); +	cmsgptr->cmsg_level = IPPROTO_IPV6; +	cmsgptr->cmsg_type = IPV6_PKTINFO; + +	pkt = (struct in6_pktinfo *)CMSG_DATA(cmsgptr); +	memset(&pkt->ipi6_addr, 0, sizeof(struct in6_addr)); +	pkt->ipi6_ifindex = ifp->ifindex; + +	ret = sendmsg(ripng->sock, &msg, 0); + +	if (ret < 0) { +		if (to) +			zlog_err("RIPng send fail on %s to %s: %s", ifp->name, +				 inet6_ntoa(to->sin6_addr), +				 safe_strerror(errno)); +		else +			zlog_err("RIPng send fail on %s: %s", ifp->name, +				 safe_strerror(errno)); +	} -  return ret; +	return ret;  }  /* Receive UDP RIPng packet from socket. */ -static int -ripng_recv_packet (int sock, u_char *buf, int bufsize, -		   struct sockaddr_in6 *from, ifindex_t *ifindex, -		   int *hoplimit) -{ -  int ret; -  struct msghdr msg; -  struct iovec iov; -  struct cmsghdr  *cmsgptr; -  struct in6_addr dst = { .s6_addr = { 0 } }; - -  memset(&dst, 0, sizeof(struct in6_addr)); - -  /* Ancillary data.  This store cmsghdr and in6_pktinfo.  But at this -     point I can't determine size of cmsghdr */ -  char adata[1024]; - -  /* Fill in message and iovec. */ -  msg.msg_name = (void *) from; -  msg.msg_namelen = sizeof (struct sockaddr_in6); -  msg.msg_iov = &iov; -  msg.msg_iovlen = 1; -  msg.msg_control = (void *) adata; -  msg.msg_controllen = sizeof adata; -  iov.iov_base = buf; -  iov.iov_len = bufsize; - -  /* If recvmsg fail return minus value. */ -  ret = recvmsg (sock, &msg, 0); -  if (ret < 0) -    return ret; - -  for (cmsgptr = ZCMSG_FIRSTHDR(&msg); cmsgptr != NULL; -       cmsgptr = CMSG_NXTHDR(&msg, cmsgptr))  -    { -      /* I want interface index which this packet comes from. */ -      if (cmsgptr->cmsg_level == IPPROTO_IPV6 && -	  cmsgptr->cmsg_type == IPV6_PKTINFO)  -	{ -	  struct in6_pktinfo *ptr; -	   -	  ptr = (struct in6_pktinfo *) CMSG_DATA (cmsgptr); -	  *ifindex = ptr->ipi6_ifindex; -	  dst = ptr->ipi6_addr; - -	  if (*ifindex == 0) -	    zlog_warn ("Interface index returned by IPV6_PKTINFO is zero"); -        } - -      /* Incoming packet's multicast hop limit. */ -      if (cmsgptr->cmsg_level == IPPROTO_IPV6 && -	  cmsgptr->cmsg_type == IPV6_HOPLIMIT) -	{ -	  int *phoplimit = (int *) CMSG_DATA (cmsgptr); -	  *hoplimit = *phoplimit; +static int ripng_recv_packet(int sock, u_char *buf, int bufsize, +			     struct sockaddr_in6 *from, ifindex_t *ifindex, +			     int *hoplimit) +{ +	int ret; +	struct msghdr msg; +	struct iovec iov; +	struct cmsghdr *cmsgptr; +	struct in6_addr dst = {.s6_addr = {0}}; + +	memset(&dst, 0, sizeof(struct in6_addr)); + +	/* Ancillary data.  This store cmsghdr and in6_pktinfo.  But at this +	   point I can't determine size of cmsghdr */ +	char adata[1024]; + +	/* Fill in message and iovec. */ +	msg.msg_name = (void *)from; +	msg.msg_namelen = sizeof(struct sockaddr_in6); +	msg.msg_iov = &iov; +	msg.msg_iovlen = 1; +	msg.msg_control = (void *)adata; +	msg.msg_controllen = sizeof adata; +	iov.iov_base = buf; +	iov.iov_len = bufsize; + +	/* If recvmsg fail return minus value. */ +	ret = recvmsg(sock, &msg, 0); +	if (ret < 0) +		return ret; + +	for (cmsgptr = ZCMSG_FIRSTHDR(&msg); cmsgptr != NULL; +	     cmsgptr = CMSG_NXTHDR(&msg, cmsgptr)) { +		/* I want interface index which this packet comes from. */ +		if (cmsgptr->cmsg_level == IPPROTO_IPV6 +		    && cmsgptr->cmsg_type == IPV6_PKTINFO) { +			struct in6_pktinfo *ptr; + +			ptr = (struct in6_pktinfo *)CMSG_DATA(cmsgptr); +			*ifindex = ptr->ipi6_ifindex; +			dst = ptr->ipi6_addr; + +			if (*ifindex == 0) +				zlog_warn( +					"Interface index returned by IPV6_PKTINFO is zero"); +		} + +		/* Incoming packet's multicast hop limit. */ +		if (cmsgptr->cmsg_level == IPPROTO_IPV6 +		    && cmsgptr->cmsg_type == IPV6_HOPLIMIT) { +			int *phoplimit = (int *)CMSG_DATA(cmsgptr); +			*hoplimit = *phoplimit; +		}  	} -    } -  /* Hoplimit check shold be done when destination address is -     multicast address. */ -  if (! IN6_IS_ADDR_MULTICAST (&dst)) -    *hoplimit = -1; +	/* Hoplimit check shold be done when destination address is +	   multicast address. */ +	if (!IN6_IS_ADDR_MULTICAST(&dst)) +		*hoplimit = -1; -  return ret; +	return ret;  }  /* Dump rip packet */ -void -ripng_packet_dump (struct ripng_packet *packet, int size, const char *sndrcv) -{ -  caddr_t lim; -  struct rte *rte; -  const char *command_str; - -  /* Set command string. */ -  if (packet->command == RIPNG_REQUEST) -    command_str = "request"; -  else if (packet->command == RIPNG_RESPONSE) -    command_str = "response"; -  else -    command_str = "unknown"; - -  /* Dump packet header. */ -  zlog_debug ("%s %s version %d packet size %d",  -	     sndrcv, command_str, packet->version, size); - -  /* Dump each routing table entry. */ -  rte = packet->rte; - -  for (lim = (caddr_t) packet + size; (caddr_t) rte < lim; rte++) -    { -      if (rte->metric == RIPNG_METRIC_NEXTHOP) -	zlog_debug ("  nexthop %s/%d", inet6_ntoa (rte->addr), rte->prefixlen); -      else -	zlog_debug ("  %s/%d metric %d tag %"ROUTE_TAG_PRI, -		   inet6_ntoa (rte->addr), rte->prefixlen,  -		   rte->metric, (route_tag_t)ntohs (rte->tag)); -    } +void ripng_packet_dump(struct ripng_packet *packet, int size, +		       const char *sndrcv) +{ +	caddr_t lim; +	struct rte *rte; +	const char *command_str; + +	/* Set command string. */ +	if (packet->command == RIPNG_REQUEST) +		command_str = "request"; +	else if (packet->command == RIPNG_RESPONSE) +		command_str = "response"; +	else +		command_str = "unknown"; + +	/* Dump packet header. */ +	zlog_debug("%s %s version %d packet size %d", sndrcv, command_str, +		   packet->version, size); + +	/* Dump each routing table entry. */ +	rte = packet->rte; + +	for (lim = (caddr_t)packet + size; (caddr_t)rte < lim; rte++) { +		if (rte->metric == RIPNG_METRIC_NEXTHOP) +			zlog_debug("  nexthop %s/%d", inet6_ntoa(rte->addr), +				   rte->prefixlen); +		else +			zlog_debug("  %s/%d metric %d tag %" ROUTE_TAG_PRI, +				   inet6_ntoa(rte->addr), rte->prefixlen, +				   rte->metric, (route_tag_t)ntohs(rte->tag)); +	}  }  /* RIPng next hop address RTE (Route Table Entry). */ -static void -ripng_nexthop_rte (struct rte *rte, -		   struct sockaddr_in6 *from, -		   struct ripng_nexthop *nexthop) -{ -  char buf[INET6_BUFSIZ]; - -  /* Logging before checking RTE. */ -  if (IS_RIPNG_DEBUG_RECV) -    zlog_debug ("RIPng nexthop RTE address %s tag %"ROUTE_TAG_PRI" prefixlen %d", -	       inet6_ntoa (rte->addr), (route_tag_t)ntohs (rte->tag), rte->prefixlen); - -  /* RFC2080 2.1.1 Next Hop:  -   The route tag and prefix length in the next hop RTE must be -   set to zero on sending and ignored on receiption.  */ -  if (ntohs (rte->tag) != 0) -    zlog_warn ("RIPng nexthop RTE with non zero tag value %"ROUTE_TAG_PRI" from %s", -	       (route_tag_t)ntohs (rte->tag), inet6_ntoa (from->sin6_addr)); - -  if (rte->prefixlen != 0) -    zlog_warn ("RIPng nexthop RTE with non zero prefixlen value %d from %s", -	       rte->prefixlen, inet6_ntoa (from->sin6_addr)); - -  /* Specifying a value of 0:0:0:0:0:0:0:0 in the prefix field of a -   next hop RTE indicates that the next hop address should be the -   originator of the RIPng advertisement.  An address specified as a -   next hop must be a link-local address.  */ -  if (IN6_IS_ADDR_UNSPECIFIED (&rte->addr)) -    { -      nexthop->flag = RIPNG_NEXTHOP_UNSPEC; -      memset (&nexthop->address, 0, sizeof (struct in6_addr)); -      return; -    } +static void ripng_nexthop_rte(struct rte *rte, struct sockaddr_in6 *from, +			      struct ripng_nexthop *nexthop) +{ +	char buf[INET6_BUFSIZ]; + +	/* Logging before checking RTE. */ +	if (IS_RIPNG_DEBUG_RECV) +		zlog_debug("RIPng nexthop RTE address %s tag %" ROUTE_TAG_PRI +			   " prefixlen %d", +			   inet6_ntoa(rte->addr), (route_tag_t)ntohs(rte->tag), +			   rte->prefixlen); + +	/* RFC2080 2.1.1 Next Hop: +	 The route tag and prefix length in the next hop RTE must be +	 set to zero on sending and ignored on receiption.  */ +	if (ntohs(rte->tag) != 0) +		zlog_warn( +			"RIPng nexthop RTE with non zero tag value %" ROUTE_TAG_PRI +			" from %s", +			(route_tag_t)ntohs(rte->tag), +			inet6_ntoa(from->sin6_addr)); + +	if (rte->prefixlen != 0) +		zlog_warn( +			"RIPng nexthop RTE with non zero prefixlen value %d from %s", +			rte->prefixlen, inet6_ntoa(from->sin6_addr)); + +	/* Specifying a value of 0:0:0:0:0:0:0:0 in the prefix field of a +	 next hop RTE indicates that the next hop address should be the +	 originator of the RIPng advertisement.  An address specified as a +	 next hop must be a link-local address.  */ +	if (IN6_IS_ADDR_UNSPECIFIED(&rte->addr)) { +		nexthop->flag = RIPNG_NEXTHOP_UNSPEC; +		memset(&nexthop->address, 0, sizeof(struct in6_addr)); +		return; +	} -  if (IN6_IS_ADDR_LINKLOCAL (&rte->addr)) -    { -      nexthop->flag = RIPNG_NEXTHOP_ADDRESS; -      IPV6_ADDR_COPY (&nexthop->address, &rte->addr); -      return; -    } +	if (IN6_IS_ADDR_LINKLOCAL(&rte->addr)) { +		nexthop->flag = RIPNG_NEXTHOP_ADDRESS; +		IPV6_ADDR_COPY(&nexthop->address, &rte->addr); +		return; +	} -  /* The purpose of the next hop RTE is to eliminate packets being -   routed through extra hops in the system.  It is particularly useful -   when RIPng is not being run on all of the routers on a network. -   Note that next hop RTE is "advisory".  That is, if the provided -   information is ignored, a possibly sub-optimal, but absolutely -   valid, route may be taken.  If the received next hop address is not -   a link-local address, it should be treated as 0:0:0:0:0:0:0:0.  */ -  zlog_warn ("RIPng nexthop RTE with non link-local address %s from %s", -	     inet6_ntoa (rte->addr), -	     inet_ntop (AF_INET6, &from->sin6_addr, buf, INET6_BUFSIZ)); +	/* The purpose of the next hop RTE is to eliminate packets being +	 routed through extra hops in the system.  It is particularly useful +	 when RIPng is not being run on all of the routers on a network. +	 Note that next hop RTE is "advisory".  That is, if the provided +	 information is ignored, a possibly sub-optimal, but absolutely +	 valid, route may be taken.  If the received next hop address is not +	 a link-local address, it should be treated as 0:0:0:0:0:0:0:0.  */ +	zlog_warn("RIPng nexthop RTE with non link-local address %s from %s", +		  inet6_ntoa(rte->addr), +		  inet_ntop(AF_INET6, &from->sin6_addr, buf, INET6_BUFSIZ)); -  nexthop->flag = RIPNG_NEXTHOP_UNSPEC; -  memset (&nexthop->address, 0, sizeof (struct in6_addr)); +	nexthop->flag = RIPNG_NEXTHOP_UNSPEC; +	memset(&nexthop->address, 0, sizeof(struct in6_addr)); -  return; +	return;  }  /* If ifp has same link-local address then return 1. */ -static int -ripng_lladdr_check (struct interface *ifp, struct in6_addr *addr) +static int ripng_lladdr_check(struct interface *ifp, struct in6_addr *addr)  { -  struct listnode *node; -  struct connected *connected; -  struct prefix *p; +	struct listnode *node; +	struct connected *connected; +	struct prefix *p; -  for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected)) -    { -      p = connected->address; +	for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, connected)) { +		p = connected->address; -      if (p->family == AF_INET6 && -          IN6_IS_ADDR_LINKLOCAL (&p->u.prefix6) && -          IN6_ARE_ADDR_EQUAL (&p->u.prefix6, addr)) -        return 1; -    } -  return 0; +		if (p->family == AF_INET6 +		    && IN6_IS_ADDR_LINKLOCAL(&p->u.prefix6) +		    && IN6_ARE_ADDR_EQUAL(&p->u.prefix6, addr)) +			return 1; +	} +	return 0;  }  /* RIPng route garbage collect timer. */ -static int -ripng_garbage_collect (struct thread *t) +static int ripng_garbage_collect(struct thread *t)  { -  struct ripng_info *rinfo; -  struct route_node *rp; +	struct ripng_info *rinfo; +	struct route_node *rp; -  rinfo = THREAD_ARG (t); -  rinfo->t_garbage_collect = NULL; +	rinfo = THREAD_ARG(t); +	rinfo->t_garbage_collect = NULL; -  /* Off timeout timer. */ -  RIPNG_TIMER_OFF (rinfo->t_timeout); -   -  /* Get route_node pointer. */ -  rp = rinfo->rp; +	/* Off timeout timer. */ +	RIPNG_TIMER_OFF(rinfo->t_timeout); -  /* Unlock route_node. */ -  listnode_delete (rp->info, rinfo); -  if (list_isempty ((struct list *)rp->info)) -    { -      list_free (rp->info); -      rp->info = NULL; -      route_unlock_node (rp); -    } +	/* Get route_node pointer. */ +	rp = rinfo->rp; + +	/* Unlock route_node. */ +	listnode_delete(rp->info, rinfo); +	if (list_isempty((struct list *)rp->info)) { +		list_free(rp->info); +		rp->info = NULL; +		route_unlock_node(rp); +	} -  /* Free RIPng routing information. */ -  ripng_info_free (rinfo); +	/* Free RIPng routing information. */ +	ripng_info_free(rinfo); -  return 0; +	return 0;  } -static void ripng_timeout_update (struct ripng_info *rinfo); +static void ripng_timeout_update(struct ripng_info *rinfo);  /* Add new route to the ECMP list.   * RETURN: the new entry added in the list, or NULL if it is not the first   *         entry and ECMP is not allowed.   */ -struct ripng_info * -ripng_ecmp_add (struct ripng_info *rinfo_new) +struct ripng_info *ripng_ecmp_add(struct ripng_info *rinfo_new)  { -  struct route_node *rp = rinfo_new->rp; -  struct ripng_info *rinfo = NULL; -  struct list *list = NULL; +	struct route_node *rp = rinfo_new->rp; +	struct ripng_info *rinfo = NULL; +	struct list *list = NULL; -  if (rp->info == NULL) -    rp->info = list_new (); -  list = (struct list *)rp->info; +	if (rp->info == NULL) +		rp->info = list_new(); +	list = (struct list *)rp->info; -  /* If ECMP is not allowed and some entry already exists in the list, -   * do nothing. */ -  if (listcount (list) && !ripng->ecmp) -    return NULL; +	/* If ECMP is not allowed and some entry already exists in the list, +	 * do nothing. */ +	if (listcount(list) && !ripng->ecmp) +		return NULL; -  rinfo = ripng_info_new (); -  memcpy (rinfo, rinfo_new, sizeof (struct ripng_info)); -  listnode_add (list, rinfo); +	rinfo = ripng_info_new(); +	memcpy(rinfo, rinfo_new, sizeof(struct ripng_info)); +	listnode_add(list, rinfo); -  if (ripng_route_rte (rinfo)) -    { -      ripng_timeout_update (rinfo); -      ripng_zebra_ipv6_add (rp); -    } +	if (ripng_route_rte(rinfo)) { +		ripng_timeout_update(rinfo); +		ripng_zebra_ipv6_add(rp); +	} -  ripng_aggregate_increment (rp, rinfo); +	ripng_aggregate_increment(rp, rinfo); -  /* Set the route change flag on the first entry. */ -  rinfo = listgetdata (listhead (list)); -  SET_FLAG (rinfo->flags, RIPNG_RTF_CHANGED); +	/* Set the route change flag on the first entry. */ +	rinfo = listgetdata(listhead(list)); +	SET_FLAG(rinfo->flags, RIPNG_RTF_CHANGED); -  /* Signal the output process to trigger an update. */ -  ripng_event (RIPNG_TRIGGERED_UPDATE, 0); +	/* Signal the output process to trigger an update. */ +	ripng_event(RIPNG_TRIGGERED_UPDATE, 0); -  return rinfo; +	return rinfo;  }  /* Replace the ECMP list with the new route.   * RETURN: the new entry added in the list   */ -struct ripng_info * -ripng_ecmp_replace (struct ripng_info *rinfo_new) -{ -  struct route_node *rp = rinfo_new->rp; -  struct list *list = (struct list *)rp->info; -  struct ripng_info *rinfo = NULL, *tmp_rinfo = NULL; -  struct listnode *node = NULL, *nextnode = NULL; - -  if (list == NULL || listcount (list) == 0) -    return ripng_ecmp_add (rinfo_new); - -  /* Get the first entry */ -  rinfo = listgetdata (listhead (list)); - -  /* Learnt route replaced by a local one. Delete it from zebra. */ -  if (ripng_route_rte (rinfo) && !ripng_route_rte (rinfo_new)) -    if (CHECK_FLAG (rinfo->flags, RIPNG_RTF_FIB)) -      ripng_zebra_ipv6_delete (rp); - -  if (rinfo->metric != RIPNG_METRIC_INFINITY) -    ripng_aggregate_decrement_list (rp, list); - -  /* Re-use the first entry, and delete the others. */ -  for (ALL_LIST_ELEMENTS (list, node, nextnode, tmp_rinfo)) -    if (tmp_rinfo != rinfo) -      { -        RIPNG_TIMER_OFF (tmp_rinfo->t_timeout); -        RIPNG_TIMER_OFF (tmp_rinfo->t_garbage_collect); -        list_delete_node (list, node); -        ripng_info_free (tmp_rinfo); -      } - -  RIPNG_TIMER_OFF (rinfo->t_timeout); -  RIPNG_TIMER_OFF (rinfo->t_garbage_collect); -  memcpy (rinfo, rinfo_new, sizeof (struct ripng_info)); - -  if (ripng_route_rte (rinfo)) -    { -      ripng_timeout_update (rinfo); -      /* The ADD message implies an update. */ -      ripng_zebra_ipv6_add (rp); -    } +struct ripng_info *ripng_ecmp_replace(struct ripng_info *rinfo_new) +{ +	struct route_node *rp = rinfo_new->rp; +	struct list *list = (struct list *)rp->info; +	struct ripng_info *rinfo = NULL, *tmp_rinfo = NULL; +	struct listnode *node = NULL, *nextnode = NULL; + +	if (list == NULL || listcount(list) == 0) +		return ripng_ecmp_add(rinfo_new); + +	/* Get the first entry */ +	rinfo = listgetdata(listhead(list)); + +	/* Learnt route replaced by a local one. Delete it from zebra. */ +	if (ripng_route_rte(rinfo) && !ripng_route_rte(rinfo_new)) +		if (CHECK_FLAG(rinfo->flags, RIPNG_RTF_FIB)) +			ripng_zebra_ipv6_delete(rp); + +	if (rinfo->metric != RIPNG_METRIC_INFINITY) +		ripng_aggregate_decrement_list(rp, list); + +	/* Re-use the first entry, and delete the others. */ +	for (ALL_LIST_ELEMENTS(list, node, nextnode, tmp_rinfo)) +		if (tmp_rinfo != rinfo) { +			RIPNG_TIMER_OFF(tmp_rinfo->t_timeout); +			RIPNG_TIMER_OFF(tmp_rinfo->t_garbage_collect); +			list_delete_node(list, node); +			ripng_info_free(tmp_rinfo); +		} -  ripng_aggregate_increment (rp, rinfo); +	RIPNG_TIMER_OFF(rinfo->t_timeout); +	RIPNG_TIMER_OFF(rinfo->t_garbage_collect); +	memcpy(rinfo, rinfo_new, sizeof(struct ripng_info)); -  /* Set the route change flag. */ -  SET_FLAG (rinfo->flags, RIPNG_RTF_CHANGED); +	if (ripng_route_rte(rinfo)) { +		ripng_timeout_update(rinfo); +		/* The ADD message implies an update. */ +		ripng_zebra_ipv6_add(rp); +	} + +	ripng_aggregate_increment(rp, rinfo); + +	/* Set the route change flag. */ +	SET_FLAG(rinfo->flags, RIPNG_RTF_CHANGED); -  /* Signal the output process to trigger an update. */ -  ripng_event (RIPNG_TRIGGERED_UPDATE, 0); +	/* Signal the output process to trigger an update. */ +	ripng_event(RIPNG_TRIGGERED_UPDATE, 0); -  return rinfo; +	return rinfo;  }  /* Delete one route from the ECMP list. @@ -541,1448 +518,1426 @@ ripng_ecmp_replace (struct ripng_info *rinfo_new)   *  the entry - the entry is the last one in the list; its metric is set   *              to INFINITY, and the garbage collector is started for it   */ -struct ripng_info * -ripng_ecmp_delete (struct ripng_info *rinfo) -{ -  struct route_node *rp = rinfo->rp; -  struct list *list = (struct list *)rp->info; - -  RIPNG_TIMER_OFF (rinfo->t_timeout); - -  if (rinfo->metric != RIPNG_METRIC_INFINITY) -    ripng_aggregate_decrement (rp, rinfo); - -  if (listcount (list) > 1) -    { -      /* Some other ECMP entries still exist. Just delete this entry. */ -      RIPNG_TIMER_OFF (rinfo->t_garbage_collect); -      listnode_delete (list, rinfo); -      if (ripng_route_rte (rinfo) && CHECK_FLAG (rinfo->flags, RIPNG_RTF_FIB)) -        /* The ADD message implies the update. */ -        ripng_zebra_ipv6_add (rp); -      ripng_info_free (rinfo); -      rinfo = NULL; -    } -  else -    { -      assert (rinfo == listgetdata (listhead (list))); - -      /* This is the only entry left in the list. We must keep it in -       * the list for garbage collection time, with INFINITY metric. */ - -      rinfo->metric = RIPNG_METRIC_INFINITY; -      RIPNG_TIMER_ON (rinfo->t_garbage_collect, -                      ripng_garbage_collect, ripng->garbage_time); - -      if (ripng_route_rte (rinfo) && CHECK_FLAG (rinfo->flags, RIPNG_RTF_FIB)) -        ripng_zebra_ipv6_delete (rp); -    } +struct ripng_info *ripng_ecmp_delete(struct ripng_info *rinfo) +{ +	struct route_node *rp = rinfo->rp; +	struct list *list = (struct list *)rp->info; + +	RIPNG_TIMER_OFF(rinfo->t_timeout); + +	if (rinfo->metric != RIPNG_METRIC_INFINITY) +		ripng_aggregate_decrement(rp, rinfo); + +	if (listcount(list) > 1) { +		/* Some other ECMP entries still exist. Just delete this entry. +		 */ +		RIPNG_TIMER_OFF(rinfo->t_garbage_collect); +		listnode_delete(list, rinfo); +		if (ripng_route_rte(rinfo) +		    && CHECK_FLAG(rinfo->flags, RIPNG_RTF_FIB)) +			/* The ADD message implies the update. */ +			ripng_zebra_ipv6_add(rp); +		ripng_info_free(rinfo); +		rinfo = NULL; +	} else { +		assert(rinfo == listgetdata(listhead(list))); + +		/* This is the only entry left in the list. We must keep it in +		 * the list for garbage collection time, with INFINITY metric. +		 */ + +		rinfo->metric = RIPNG_METRIC_INFINITY; +		RIPNG_TIMER_ON(rinfo->t_garbage_collect, ripng_garbage_collect, +			       ripng->garbage_time); + +		if (ripng_route_rte(rinfo) +		    && CHECK_FLAG(rinfo->flags, RIPNG_RTF_FIB)) +			ripng_zebra_ipv6_delete(rp); +	} -  /* Set the route change flag on the first entry. */ -  rinfo = listgetdata (listhead (list)); -  SET_FLAG (rinfo->flags, RIPNG_RTF_CHANGED); +	/* Set the route change flag on the first entry. */ +	rinfo = listgetdata(listhead(list)); +	SET_FLAG(rinfo->flags, RIPNG_RTF_CHANGED); -  /* Signal the output process to trigger an update. */ -  ripng_event (RIPNG_TRIGGERED_UPDATE, 0); +	/* Signal the output process to trigger an update. */ +	ripng_event(RIPNG_TRIGGERED_UPDATE, 0); -  return rinfo; +	return rinfo;  }  /* Timeout RIPng routes. */ -static int -ripng_timeout (struct thread *t) +static int ripng_timeout(struct thread *t)  { -  ripng_ecmp_delete ((struct ripng_info *)THREAD_ARG (t)); -  return 0; +	ripng_ecmp_delete((struct ripng_info *)THREAD_ARG(t)); +	return 0;  } -static void -ripng_timeout_update (struct ripng_info *rinfo) +static void ripng_timeout_update(struct ripng_info *rinfo)  { -  if (rinfo->metric != RIPNG_METRIC_INFINITY) -    { -      RIPNG_TIMER_OFF (rinfo->t_timeout); -      RIPNG_TIMER_ON (rinfo->t_timeout, ripng_timeout, ripng->timeout_time); -    } +	if (rinfo->metric != RIPNG_METRIC_INFINITY) { +		RIPNG_TIMER_OFF(rinfo->t_timeout); +		RIPNG_TIMER_ON(rinfo->t_timeout, ripng_timeout, +			       ripng->timeout_time); +	}  } -static int -ripng_filter (int ripng_distribute, struct prefix_ipv6 *p, -              struct ripng_interface *ri) -{ -  struct distribute *dist; -  struct access_list *alist; -  struct prefix_list *plist; -  int distribute = ripng_distribute == RIPNG_FILTER_OUT ? -      DISTRIBUTE_V6_OUT : DISTRIBUTE_V6_IN; -  const char *inout = ripng_distribute == RIPNG_FILTER_OUT ? "out" : "in"; - -  /* Input distribute-list filtering. */ -  if (ri->list[ripng_distribute]) -    { -      if (access_list_apply (ri->list[ripng_distribute], -			     (struct prefix *) p) == FILTER_DENY) -	{ -	  if (IS_RIPNG_DEBUG_PACKET) -	    zlog_debug ("%s/%d filtered by distribute %s", -                        inet6_ntoa (p->prefix), p->prefixlen, inout); -		  return -1; +static int ripng_filter(int ripng_distribute, struct prefix_ipv6 *p, +			struct ripng_interface *ri) +{ +	struct distribute *dist; +	struct access_list *alist; +	struct prefix_list *plist; +	int distribute = ripng_distribute == RIPNG_FILTER_OUT +				 ? DISTRIBUTE_V6_OUT +				 : DISTRIBUTE_V6_IN; +	const char *inout = ripng_distribute == RIPNG_FILTER_OUT ? "out" : "in"; + +	/* Input distribute-list filtering. */ +	if (ri->list[ripng_distribute]) { +		if (access_list_apply(ri->list[ripng_distribute], +				      (struct prefix *)p) +		    == FILTER_DENY) { +			if (IS_RIPNG_DEBUG_PACKET) +				zlog_debug("%s/%d filtered by distribute %s", +					   inet6_ntoa(p->prefix), p->prefixlen, +					   inout); +			return -1; +		} +	} +	if (ri->prefix[ripng_distribute]) { +		if (prefix_list_apply(ri->prefix[ripng_distribute], +				      (struct prefix *)p) +		    == PREFIX_DENY) { +			if (IS_RIPNG_DEBUG_PACKET) +				zlog_debug("%s/%d filtered by prefix-list %s", +					   inet6_ntoa(p->prefix), p->prefixlen, +					   inout); +			return -1;  		} -	    } -  if (ri->prefix[ripng_distribute]) -{ -      if (prefix_list_apply (ri->prefix[ripng_distribute], -			     (struct prefix *) p) == PREFIX_DENY) -	{ -	  if (IS_RIPNG_DEBUG_PACKET) -	    zlog_debug ("%s/%d filtered by prefix-list %s", -                        inet6_ntoa (p->prefix), p->prefixlen, inout); -	  return -1;  	} -    } -  /* All interface filter check. */ -  dist = distribute_lookup (NULL); -  if (dist) -    { -      if (dist->list[distribute]) -	{ -	  alist = access_list_lookup (AFI_IP6, dist->list[distribute]); -	     -	  if (alist) -	    { -	      if (access_list_apply (alist, -				     (struct prefix *) p) == FILTER_DENY) -		{ -		  if (IS_RIPNG_DEBUG_PACKET) -		    zlog_debug ("%s/%d filtered by distribute %s", -                                inet6_ntoa (p->prefix), p->prefixlen, inout); -		  return -1; +	/* All interface filter check. */ +	dist = distribute_lookup(NULL); +	if (dist) { +		if (dist->list[distribute]) { +			alist = access_list_lookup(AFI_IP6, +						   dist->list[distribute]); + +			if (alist) { +				if (access_list_apply(alist, (struct prefix *)p) +				    == FILTER_DENY) { +					if (IS_RIPNG_DEBUG_PACKET) +						zlog_debug( +							"%s/%d filtered by distribute %s", +							inet6_ntoa(p->prefix), +							p->prefixlen, inout); +					return -1; +				} +			}  		} -	    } -	} -      if (dist->prefix[distribute]) -	{ -	  plist = prefix_list_lookup (AFI_IP6, dist->prefix[distribute]); -	   -	  if (plist) -	    { -	      if (prefix_list_apply (plist, -				     (struct prefix *) p) == PREFIX_DENY) -		{ -		  if (IS_RIPNG_DEBUG_PACKET) -		    zlog_debug ("%s/%d filtered by prefix-list %s", -                                inet6_ntoa (p->prefix), p->prefixlen, inout); -		  return -1; +		if (dist->prefix[distribute]) { +			plist = prefix_list_lookup(AFI_IP6, +						   dist->prefix[distribute]); + +			if (plist) { +				if (prefix_list_apply(plist, (struct prefix *)p) +				    == PREFIX_DENY) { +					if (IS_RIPNG_DEBUG_PACKET) +						zlog_debug( +							"%s/%d filtered by prefix-list %s", +							inet6_ntoa(p->prefix), +							p->prefixlen, inout); +					return -1; +				} +			}  		} -	    }  	} -    } -  return 0; +	return 0;  }  /* Process RIPng route according to RFC2080. */ -static void -ripng_route_process (struct rte *rte, struct sockaddr_in6 *from, -		     struct ripng_nexthop *ripng_nexthop, -		     struct interface *ifp) -{ -  int ret; -  struct prefix_ipv6 p; -  struct route_node *rp; -  struct ripng_info *rinfo = NULL, newinfo; -  struct ripng_interface *ri; -  struct in6_addr *nexthop; -  int same = 0; -  struct list *list = NULL; -  struct listnode *node = NULL; - -  /* Make prefix structure. */ -  memset (&p, 0, sizeof (struct prefix_ipv6)); -  p.family = AF_INET6; -  /* p.prefix = rte->addr; */ -  IPV6_ADDR_COPY (&p.prefix, &rte->addr); -  p.prefixlen = rte->prefixlen; - -  /* Make sure mask is applied. */ -  /* XXX We have to check the prefix is valid or not before call -     apply_mask_ipv6. */ -  apply_mask_ipv6 (&p); - -  /* Apply input filters. */ -  ri = ifp->info; - -  ret = ripng_filter (RIPNG_FILTER_IN, &p, ri); -  if (ret < 0) -    return; - -  memset (&newinfo, 0, sizeof (newinfo)); -  newinfo.type = ZEBRA_ROUTE_RIPNG; -  newinfo.sub_type = RIPNG_ROUTE_RTE; -  if (ripng_nexthop->flag == RIPNG_NEXTHOP_ADDRESS) -    newinfo.nexthop = ripng_nexthop->address; -  else -    newinfo.nexthop = from->sin6_addr; -  newinfo.from = from->sin6_addr; -  newinfo.ifindex = ifp->ifindex; -  newinfo.metric = rte->metric; -  newinfo.metric_out = rte->metric; /* XXX */ -  newinfo.tag = ntohs (rte->tag);   /* XXX */ - -  /* Modify entry. */ -  if (ri->routemap[RIPNG_FILTER_IN]) -    { -      int ret; - -      ret = route_map_apply (ri->routemap[RIPNG_FILTER_IN],  -			     (struct prefix *)&p, RMAP_RIPNG, &newinfo); - -      if (ret == RMAP_DENYMATCH) -	{ -	  if (IS_RIPNG_DEBUG_PACKET) -	    zlog_debug ("RIPng %s/%d is filtered by route-map in", -		       inet6_ntoa (p.prefix), p.prefixlen); -	  return; -	} - -      /* Get back the object */ -      if (ripng_nexthop->flag == RIPNG_NEXTHOP_ADDRESS) { -	if (! IPV6_ADDR_SAME(&newinfo.nexthop, &ripng_nexthop->address) ) { -	  /* the nexthop get changed by the routemap */ -	  if (IN6_IS_ADDR_LINKLOCAL(&newinfo.nexthop)) -	    ripng_nexthop->address = newinfo.nexthop; -	  else -	    ripng_nexthop->address = in6addr_any; -	} -      } else { -	if (! IPV6_ADDR_SAME(&newinfo.nexthop, &from->sin6_addr) ) { -	  /* the nexthop get changed by the routemap */ -	  if (IN6_IS_ADDR_LINKLOCAL(&newinfo.nexthop)) { -	    ripng_nexthop->flag = RIPNG_NEXTHOP_ADDRESS; -	    ripng_nexthop->address = newinfo.nexthop; -	  } -	} -      } -      rte->tag     = htons(newinfo.tag_out); /* XXX */ -      rte->metric  = newinfo.metric_out; /* XXX: the routemap uses the metric_out field */ -    } +static void ripng_route_process(struct rte *rte, struct sockaddr_in6 *from, +				struct ripng_nexthop *ripng_nexthop, +				struct interface *ifp) +{ +	int ret; +	struct prefix_ipv6 p; +	struct route_node *rp; +	struct ripng_info *rinfo = NULL, newinfo; +	struct ripng_interface *ri; +	struct in6_addr *nexthop; +	int same = 0; +	struct list *list = NULL; +	struct listnode *node = NULL; + +	/* Make prefix structure. */ +	memset(&p, 0, sizeof(struct prefix_ipv6)); +	p.family = AF_INET6; +	/* p.prefix = rte->addr; */ +	IPV6_ADDR_COPY(&p.prefix, &rte->addr); +	p.prefixlen = rte->prefixlen; + +	/* Make sure mask is applied. */ +	/* XXX We have to check the prefix is valid or not before call +	   apply_mask_ipv6. */ +	apply_mask_ipv6(&p); + +	/* Apply input filters. */ +	ri = ifp->info; + +	ret = ripng_filter(RIPNG_FILTER_IN, &p, ri); +	if (ret < 0) +		return; + +	memset(&newinfo, 0, sizeof(newinfo)); +	newinfo.type = ZEBRA_ROUTE_RIPNG; +	newinfo.sub_type = RIPNG_ROUTE_RTE; +	if (ripng_nexthop->flag == RIPNG_NEXTHOP_ADDRESS) +		newinfo.nexthop = ripng_nexthop->address; +	else +		newinfo.nexthop = from->sin6_addr; +	newinfo.from = from->sin6_addr; +	newinfo.ifindex = ifp->ifindex; +	newinfo.metric = rte->metric; +	newinfo.metric_out = rte->metric; /* XXX */ +	newinfo.tag = ntohs(rte->tag);    /* XXX */ + +	/* Modify entry. */ +	if (ri->routemap[RIPNG_FILTER_IN]) { +		int ret; + +		ret = route_map_apply(ri->routemap[RIPNG_FILTER_IN], +				      (struct prefix *)&p, RMAP_RIPNG, +				      &newinfo); + +		if (ret == RMAP_DENYMATCH) { +			if (IS_RIPNG_DEBUG_PACKET) +				zlog_debug( +					"RIPng %s/%d is filtered by route-map in", +					inet6_ntoa(p.prefix), p.prefixlen); +			return; +		} -  /* Once the entry has been validated, update the metric by -   * adding the cost of the network on wich the message -   * arrived. If the result is greater than infinity, use infinity -   * (RFC2453 Sec. 3.9.2) -   **/ -  -  /* Zebra ripngd can handle offset-list in. */ -  ret = ripng_offset_list_apply_in (&p, ifp, &rte->metric); - -  /* If offset-list does not modify the metric use interface's -   * one. */ -  if (! ret) -    rte->metric += ifp->metric ? ifp->metric : 1; - -  if (rte->metric > RIPNG_METRIC_INFINITY) -    rte->metric = RIPNG_METRIC_INFINITY; - -  /* Set nexthop pointer. */ -  if (ripng_nexthop->flag == RIPNG_NEXTHOP_ADDRESS) -    nexthop = &ripng_nexthop->address; -  else -    nexthop = &from->sin6_addr; - -  /* Lookup RIPng routing table. */ -  rp = route_node_get (ripng->table, (struct prefix *) &p); - -  newinfo.rp = rp; -  newinfo.nexthop = *nexthop; -  newinfo.metric = rte->metric; -  newinfo.tag = ntohs (rte->tag); - -  /* Check to see whether there is already RIPng route on the table. */ -  if ((list = rp->info) != NULL) -    for (ALL_LIST_ELEMENTS_RO (list, node, rinfo)) -      { -        /* Need to compare with redistributed entry or local entry */ -        if (!ripng_route_rte (rinfo)) -          break; - -        if (IPV6_ADDR_SAME (&rinfo->from, &from->sin6_addr) && -            IPV6_ADDR_SAME (&rinfo->nexthop, nexthop)) -          break; - -        if (!listnextnode (node)) -          { -            /* Not found in the list */ - -            if (rte->metric > rinfo->metric) -              { -                /* New route has a greater metric. Discard it. */ -                route_unlock_node (rp); -                return; -              } - -            if (rte->metric < rinfo->metric) -              /* New route has a smaller metric. Replace the ECMP list -               * with the new one in below. */ -              break; - -            /* Metrics are same. Unless ECMP is disabled, keep "rinfo" null and -	     * the new route is added in the ECMP list in below. */ -	    if (! ripng->ecmp) -	      break; -          } -      } - -  if (rinfo) -    { -      /* Redistributed route check. */ -      if (rinfo->type != ZEBRA_ROUTE_RIPNG -	  && rinfo->metric != RIPNG_METRIC_INFINITY) -        { -          route_unlock_node (rp); -          return; -        } - -      /* Local static route. */ -      if (rinfo->type == ZEBRA_ROUTE_RIPNG -	  && ((rinfo->sub_type == RIPNG_ROUTE_STATIC) || -	      (rinfo->sub_type == RIPNG_ROUTE_DEFAULT)) -	  && rinfo->metric != RIPNG_METRIC_INFINITY) -        { -          route_unlock_node (rp); -          return; -        } -    } +		/* Get back the object */ +		if (ripng_nexthop->flag == RIPNG_NEXTHOP_ADDRESS) { +			if (!IPV6_ADDR_SAME(&newinfo.nexthop, +					    &ripng_nexthop->address)) { +				/* the nexthop get changed by the routemap */ +				if (IN6_IS_ADDR_LINKLOCAL(&newinfo.nexthop)) +					ripng_nexthop->address = +						newinfo.nexthop; +				else +					ripng_nexthop->address = in6addr_any; +			} +		} else { +			if (!IPV6_ADDR_SAME(&newinfo.nexthop, +					    &from->sin6_addr)) { +				/* the nexthop get changed by the routemap */ +				if (IN6_IS_ADDR_LINKLOCAL(&newinfo.nexthop)) { +					ripng_nexthop->flag = +						RIPNG_NEXTHOP_ADDRESS; +					ripng_nexthop->address = +						newinfo.nexthop; +				} +			} +		} +		rte->tag = htons(newinfo.tag_out); /* XXX */ +		rte->metric = +			newinfo.metric_out; /* XXX: the routemap uses the +					       metric_out field */ +	} -  if (!rinfo) -    { -      /* Now, check to see whether there is already an explicit route -	 for the destination prefix.  If there is no such route, add -	 this route to the routing table, unless the metric is -	 infinity (there is no point in adding a route which -	 unusable). */ -      if (rte->metric != RIPNG_METRIC_INFINITY) -        ripng_ecmp_add (&newinfo); -    } -  else -    { -      /* If there is an existing route, compare the next hop address -	 to the address of the router from which the datagram came. -	 If this datagram is from the same router as the existing -	 route, reinitialize the timeout.  */ -      same = (IN6_ARE_ADDR_EQUAL (&rinfo->from, &from->sin6_addr)  -	      && (rinfo->ifindex == ifp->ifindex)); - -      /* -       * RFC 2080 - Section 2.4.2: -       * "If the new metric is the same as the old one, examine the timeout -       * for the existing route.  If it is at least halfway to the expiration -       * point, switch to the new route.  This heuristic is optional, but -       * highly recommended". -       */ -      if (!ripng->ecmp && !same && -	  rinfo->metric == rte->metric && rinfo->t_timeout && -	  (thread_timer_remain_second (rinfo->t_timeout) < (ripng->timeout_time / 2))) -	{ -	  ripng_ecmp_replace (&newinfo); -	} -      /* Next, compare the metrics.  If the datagram is from the same -	 router as the existing route, and the new metric is different -	 than the old one; or, if the new metric is lower than the old -	 one; do the following actions: */ -      else if ((same && rinfo->metric != rte->metric) || -	  rte->metric < rinfo->metric) -	{ -          if (listcount (list) == 1) -            { -              if (newinfo.metric != RIPNG_METRIC_INFINITY) -                ripng_ecmp_replace (&newinfo); -              else -                ripng_ecmp_delete (rinfo); -            } -          else -            { -              if (newinfo.metric < rinfo->metric) -                ripng_ecmp_replace (&newinfo); -              else /* newinfo.metric > rinfo->metric */ -                ripng_ecmp_delete (rinfo); -            } -	} -      else /* same & no change */ -        ripng_timeout_update (rinfo); - -      /* Unlock tempolary lock of the route. */ -      route_unlock_node (rp); -    } -} +	/* Once the entry has been validated, update the metric by +	 * adding the cost of the network on wich the message +	 * arrived. If the result is greater than infinity, use infinity +	 * (RFC2453 Sec. 3.9.2) +	 **/ + +	/* Zebra ripngd can handle offset-list in. */ +	ret = ripng_offset_list_apply_in(&p, ifp, &rte->metric); + +	/* If offset-list does not modify the metric use interface's +	 * one. */ +	if (!ret) +		rte->metric += ifp->metric ? ifp->metric : 1; + +	if (rte->metric > RIPNG_METRIC_INFINITY) +		rte->metric = RIPNG_METRIC_INFINITY; + +	/* Set nexthop pointer. */ +	if (ripng_nexthop->flag == RIPNG_NEXTHOP_ADDRESS) +		nexthop = &ripng_nexthop->address; +	else +		nexthop = &from->sin6_addr; + +	/* Lookup RIPng routing table. */ +	rp = route_node_get(ripng->table, (struct prefix *)&p); + +	newinfo.rp = rp; +	newinfo.nexthop = *nexthop; +	newinfo.metric = rte->metric; +	newinfo.tag = ntohs(rte->tag); + +	/* Check to see whether there is already RIPng route on the table. */ +	if ((list = rp->info) != NULL) +		for (ALL_LIST_ELEMENTS_RO(list, node, rinfo)) { +			/* Need to compare with redistributed entry or local +			 * entry */ +			if (!ripng_route_rte(rinfo)) +				break; + +			if (IPV6_ADDR_SAME(&rinfo->from, &from->sin6_addr) +			    && IPV6_ADDR_SAME(&rinfo->nexthop, nexthop)) +				break; + +			if (!listnextnode(node)) { +				/* Not found in the list */ + +				if (rte->metric > rinfo->metric) { +					/* New route has a greater metric. +					 * Discard it. */ +					route_unlock_node(rp); +					return; +				} + +				if (rte->metric < rinfo->metric) +					/* New route has a smaller metric. +					 * Replace the ECMP list +					 * with the new one in below. */ +					break; + +				/* Metrics are same. Unless ECMP is disabled, +				 * keep "rinfo" null and +				 * the new route is added in the ECMP list in +				 * below. */ +				if (!ripng->ecmp) +					break; +			} +		} -/* Add redistributed route to RIPng table. */ -void -ripng_redistribute_add (int type, int sub_type, struct prefix_ipv6 *p,  -			ifindex_t ifindex, struct in6_addr *nexthop, -			route_tag_t tag) -{ -  struct route_node *rp; -  struct ripng_info *rinfo = NULL, newinfo; -  struct list *list = NULL; - -  /* Redistribute route  */ -  if (IN6_IS_ADDR_LINKLOCAL (&p->prefix)) -    return; -  if (IN6_IS_ADDR_LOOPBACK (&p->prefix)) -    return; - -  rp = route_node_get (ripng->table, (struct prefix *) p); - -  memset (&newinfo, 0, sizeof (struct ripng_info)); -  newinfo.type = type; -  newinfo.sub_type = sub_type; -  newinfo.ifindex = ifindex; -  newinfo.metric = 1; -  if (tag <= UINT16_MAX) /* RIPng only supports 16 bit tags */ -    newinfo.tag = tag; -  newinfo.rp = rp; -  if (nexthop && IN6_IS_ADDR_LINKLOCAL(nexthop)) -    newinfo.nexthop = *nexthop; - -  if ((list = rp->info) != NULL && listcount (list) != 0) -    { -      rinfo = listgetdata (listhead (list)); - -      if (rinfo->type == ZEBRA_ROUTE_CONNECT -          && rinfo->sub_type == RIPNG_ROUTE_INTERFACE -	  && rinfo->metric != RIPNG_METRIC_INFINITY) { -        route_unlock_node (rp); -	   return; -      } - -      /* Manually configured RIPng route check. -       * They have the precedence on all the other entries. -       **/ -      if (rinfo->type == ZEBRA_ROUTE_RIPNG -          && ((rinfo->sub_type == RIPNG_ROUTE_STATIC) || -              (rinfo->sub_type == RIPNG_ROUTE_DEFAULT)) ) { -        if (type != ZEBRA_ROUTE_RIPNG || ((sub_type != RIPNG_ROUTE_STATIC) && -                                          (sub_type != RIPNG_ROUTE_DEFAULT))) { -	  route_unlock_node (rp); -	  return; -	} -      } - -      ripng_ecmp_replace (&newinfo); -      route_unlock_node (rp); -    } -  else -    ripng_ecmp_add (&newinfo); +	if (rinfo) { +		/* Redistributed route check. */ +		if (rinfo->type != ZEBRA_ROUTE_RIPNG +		    && rinfo->metric != RIPNG_METRIC_INFINITY) { +			route_unlock_node(rp); +			return; +		} -  if (IS_RIPNG_DEBUG_EVENT) { -    if (!nexthop) -      zlog_debug ("Redistribute new prefix %s/%d on the interface %s", -                  inet6_ntoa(p->prefix), p->prefixlen, -                  ifindex2ifname(ifindex, VRF_DEFAULT)); -    else -      zlog_debug ("Redistribute new prefix %s/%d with nexthop %s on the interface %s", -                  inet6_ntoa(p->prefix), p->prefixlen, inet6_ntoa(*nexthop), -                  ifindex2ifname(ifindex, VRF_DEFAULT)); -  } +		/* Local static route. */ +		if (rinfo->type == ZEBRA_ROUTE_RIPNG +		    && ((rinfo->sub_type == RIPNG_ROUTE_STATIC) +			|| (rinfo->sub_type == RIPNG_ROUTE_DEFAULT)) +		    && rinfo->metric != RIPNG_METRIC_INFINITY) { +			route_unlock_node(rp); +			return; +		} +	} -  ripng_event (RIPNG_TRIGGERED_UPDATE, 0); +	if (!rinfo) { +		/* Now, check to see whether there is already an explicit route +		   for the destination prefix.  If there is no such route, add +		   this route to the routing table, unless the metric is +		   infinity (there is no point in adding a route which +		   unusable). */ +		if (rte->metric != RIPNG_METRIC_INFINITY) +			ripng_ecmp_add(&newinfo); +	} else { +		/* If there is an existing route, compare the next hop address +		   to the address of the router from which the datagram came. +		   If this datagram is from the same router as the existing +		   route, reinitialize the timeout.  */ +		same = (IN6_ARE_ADDR_EQUAL(&rinfo->from, &from->sin6_addr) +			&& (rinfo->ifindex == ifp->ifindex)); + +		/* +		 * RFC 2080 - Section 2.4.2: +		 * "If the new metric is the same as the old one, examine the +		 * timeout +		 * for the existing route.  If it is at least halfway to the +		 * expiration +		 * point, switch to the new route.  This heuristic is optional, +		 * but +		 * highly recommended". +		 */ +		if (!ripng->ecmp && !same && rinfo->metric == rte->metric +		    && rinfo->t_timeout +		    && (thread_timer_remain_second(rinfo->t_timeout) +			< (ripng->timeout_time / 2))) { +			ripng_ecmp_replace(&newinfo); +		} +		/* Next, compare the metrics.  If the datagram is from the same +		   router as the existing route, and the new metric is different +		   than the old one; or, if the new metric is lower than the old +		   one; do the following actions: */ +		else if ((same && rinfo->metric != rte->metric) +			 || rte->metric < rinfo->metric) { +			if (listcount(list) == 1) { +				if (newinfo.metric != RIPNG_METRIC_INFINITY) +					ripng_ecmp_replace(&newinfo); +				else +					ripng_ecmp_delete(rinfo); +			} else { +				if (newinfo.metric < rinfo->metric) +					ripng_ecmp_replace(&newinfo); +				else /* newinfo.metric > rinfo->metric */ +					ripng_ecmp_delete(rinfo); +			} +		} else /* same & no change */ +			ripng_timeout_update(rinfo); + +		/* Unlock tempolary lock of the route. */ +		route_unlock_node(rp); +	}  } -/* Delete redistributed route to RIPng table. */ -void -ripng_redistribute_delete (int type, int sub_type, struct prefix_ipv6 *p,  -			   ifindex_t ifindex) -{ -  struct route_node *rp; -  struct ripng_info *rinfo; +/* Add redistributed route to RIPng table. */ +void ripng_redistribute_add(int type, int sub_type, struct prefix_ipv6 *p, +			    ifindex_t ifindex, struct in6_addr *nexthop, +			    route_tag_t tag) +{ +	struct route_node *rp; +	struct ripng_info *rinfo = NULL, newinfo; +	struct list *list = NULL; + +	/* Redistribute route  */ +	if (IN6_IS_ADDR_LINKLOCAL(&p->prefix)) +		return; +	if (IN6_IS_ADDR_LOOPBACK(&p->prefix)) +		return; + +	rp = route_node_get(ripng->table, (struct prefix *)p); + +	memset(&newinfo, 0, sizeof(struct ripng_info)); +	newinfo.type = type; +	newinfo.sub_type = sub_type; +	newinfo.ifindex = ifindex; +	newinfo.metric = 1; +	if (tag <= UINT16_MAX) /* RIPng only supports 16 bit tags */ +		newinfo.tag = tag; +	newinfo.rp = rp; +	if (nexthop && IN6_IS_ADDR_LINKLOCAL(nexthop)) +		newinfo.nexthop = *nexthop; + +	if ((list = rp->info) != NULL && listcount(list) != 0) { +		rinfo = listgetdata(listhead(list)); + +		if (rinfo->type == ZEBRA_ROUTE_CONNECT +		    && rinfo->sub_type == RIPNG_ROUTE_INTERFACE +		    && rinfo->metric != RIPNG_METRIC_INFINITY) { +			route_unlock_node(rp); +			return; +		} + +		/* Manually configured RIPng route check. +		 * They have the precedence on all the other entries. +		 **/ +		if (rinfo->type == ZEBRA_ROUTE_RIPNG +		    && ((rinfo->sub_type == RIPNG_ROUTE_STATIC) +			|| (rinfo->sub_type == RIPNG_ROUTE_DEFAULT))) { +			if (type != ZEBRA_ROUTE_RIPNG +			    || ((sub_type != RIPNG_ROUTE_STATIC) +				&& (sub_type != RIPNG_ROUTE_DEFAULT))) { +				route_unlock_node(rp); +				return; +			} +		} -  if (IN6_IS_ADDR_LINKLOCAL (&p->prefix)) -    return; -  if (IN6_IS_ADDR_LOOPBACK (&p->prefix)) -    return; +		ripng_ecmp_replace(&newinfo); +		route_unlock_node(rp); +	} else +		ripng_ecmp_add(&newinfo); + +	if (IS_RIPNG_DEBUG_EVENT) { +		if (!nexthop) +			zlog_debug( +				"Redistribute new prefix %s/%d on the interface %s", +				inet6_ntoa(p->prefix), p->prefixlen, +				ifindex2ifname(ifindex, VRF_DEFAULT)); +		else +			zlog_debug( +				"Redistribute new prefix %s/%d with nexthop %s on the interface %s", +				inet6_ntoa(p->prefix), p->prefixlen, +				inet6_ntoa(*nexthop), +				ifindex2ifname(ifindex, VRF_DEFAULT)); +	} -  rp = route_node_lookup (ripng->table, (struct prefix *) p); +	ripng_event(RIPNG_TRIGGERED_UPDATE, 0); +} -  if (rp) -    { -      struct list *list = rp->info; - -      if (list != NULL && listcount (list) != 0) -        { -          rinfo = listgetdata (listhead (list)); -          if (rinfo != NULL -              && rinfo->type == type -              && rinfo->sub_type == sub_type -              && rinfo->ifindex == ifindex) -            { -              /* Perform poisoned reverse. */ -              rinfo->metric = RIPNG_METRIC_INFINITY; -              RIPNG_TIMER_ON (rinfo->t_garbage_collect, -                              ripng_garbage_collect, ripng->garbage_time); -              RIPNG_TIMER_OFF (rinfo->t_timeout); - -              /* Aggregate count decrement. */ -              ripng_aggregate_decrement (rp, rinfo); - -              rinfo->flags |= RIPNG_RTF_CHANGED; - -              if (IS_RIPNG_DEBUG_EVENT) -                zlog_debug ("Poisone %s/%d on the interface %s with an " -                            "infinity metric [delete]", -                            inet6_ntoa (p->prefix), p->prefixlen, -                            ifindex2ifname (ifindex, VRF_DEFAULT)); - -              ripng_event (RIPNG_TRIGGERED_UPDATE, 0); -            } -        } -      route_unlock_node (rp); -    } +/* Delete redistributed route to RIPng table. */ +void ripng_redistribute_delete(int type, int sub_type, struct prefix_ipv6 *p, +			       ifindex_t ifindex) +{ +	struct route_node *rp; +	struct ripng_info *rinfo; + +	if (IN6_IS_ADDR_LINKLOCAL(&p->prefix)) +		return; +	if (IN6_IS_ADDR_LOOPBACK(&p->prefix)) +		return; + +	rp = route_node_lookup(ripng->table, (struct prefix *)p); + +	if (rp) { +		struct list *list = rp->info; + +		if (list != NULL && listcount(list) != 0) { +			rinfo = listgetdata(listhead(list)); +			if (rinfo != NULL && rinfo->type == type +			    && rinfo->sub_type == sub_type +			    && rinfo->ifindex == ifindex) { +				/* Perform poisoned reverse. */ +				rinfo->metric = RIPNG_METRIC_INFINITY; +				RIPNG_TIMER_ON(rinfo->t_garbage_collect, +					       ripng_garbage_collect, +					       ripng->garbage_time); +				RIPNG_TIMER_OFF(rinfo->t_timeout); + +				/* Aggregate count decrement. */ +				ripng_aggregate_decrement(rp, rinfo); + +				rinfo->flags |= RIPNG_RTF_CHANGED; + +				if (IS_RIPNG_DEBUG_EVENT) +					zlog_debug( +						"Poisone %s/%d on the interface %s with an " +						"infinity metric [delete]", +						inet6_ntoa(p->prefix), +						p->prefixlen, +						ifindex2ifname(ifindex, +							       VRF_DEFAULT)); + +				ripng_event(RIPNG_TRIGGERED_UPDATE, 0); +			} +		} +		route_unlock_node(rp); +	}  }  /* Withdraw redistributed route. */ -void -ripng_redistribute_withdraw (int type) -{ -  struct route_node *rp; -  struct ripng_info *rinfo = NULL; -  struct list *list = NULL; +void ripng_redistribute_withdraw(int type) +{ +	struct route_node *rp; +	struct ripng_info *rinfo = NULL; +	struct list *list = NULL; + +	if (!ripng) +		return; + +	for (rp = route_top(ripng->table); rp; rp = route_next(rp)) +		if ((list = rp->info) != NULL) { +			rinfo = listgetdata(listhead(list)); +			if ((rinfo->type == type) +			    && (rinfo->sub_type != RIPNG_ROUTE_INTERFACE)) { +				/* Perform poisoned reverse. */ +				rinfo->metric = RIPNG_METRIC_INFINITY; +				RIPNG_TIMER_ON(rinfo->t_garbage_collect, +					       ripng_garbage_collect, +					       ripng->garbage_time); +				RIPNG_TIMER_OFF(rinfo->t_timeout); + +				/* Aggregate count decrement. */ +				ripng_aggregate_decrement(rp, rinfo); + +				rinfo->flags |= RIPNG_RTF_CHANGED; + +				if (IS_RIPNG_DEBUG_EVENT) { +					struct prefix_ipv6 *p = +						(struct prefix_ipv6 *)&rp->p; + +					zlog_debug( +						"Poisone %s/%d on the interface %s [withdraw]", +						inet6_ntoa(p->prefix), +						p->prefixlen, +						ifindex2ifname(rinfo->ifindex, +							       VRF_DEFAULT)); +				} + +				ripng_event(RIPNG_TRIGGERED_UPDATE, 0); +			} +		} +} -  if (!ripng) -    return; -   -  for (rp = route_top (ripng->table); rp; rp = route_next (rp)) -    if ((list = rp->info) != NULL) -      { -	rinfo = listgetdata (listhead (list)); -	if ((rinfo->type == type) -	    && (rinfo->sub_type != RIPNG_ROUTE_INTERFACE)) -	  { -	    /* Perform poisoned reverse. */ -	    rinfo->metric = RIPNG_METRIC_INFINITY; -	    RIPNG_TIMER_ON (rinfo->t_garbage_collect,  -			  ripng_garbage_collect, ripng->garbage_time); -	    RIPNG_TIMER_OFF (rinfo->t_timeout); +/* RIP routing information. */ +static void ripng_response_process(struct ripng_packet *packet, int size, +				   struct sockaddr_in6 *from, +				   struct interface *ifp, int hoplimit) +{ +	caddr_t lim; +	struct rte *rte; +	struct ripng_nexthop nexthop; + +	/* RFC2080 2.4.2  Response Messages: +	 The Response must be ignored if it is not from the RIPng port.  */ +	if (ntohs(from->sin6_port) != RIPNG_PORT_DEFAULT) { +		zlog_warn("RIPng packet comes from non RIPng port %d from %s", +			  ntohs(from->sin6_port), inet6_ntoa(from->sin6_addr)); +		ripng_peer_bad_packet(from); +		return; +	} -	    /* Aggregate count decrement. */ -	    ripng_aggregate_decrement (rp, rinfo); +	/* The datagram's IPv6 source address should be checked to see +	 whether the datagram is from a valid neighbor; the source of the +	 datagram must be a link-local address.  */ +	if (!IN6_IS_ADDR_LINKLOCAL(&from->sin6_addr)) { +		zlog_warn("RIPng packet comes from non link local address %s", +			  inet6_ntoa(from->sin6_addr)); +		ripng_peer_bad_packet(from); +		return; +	} -	    rinfo->flags |= RIPNG_RTF_CHANGED; +	/* It is also worth checking to see whether the response is from one +	 of the router's own addresses.  Interfaces on broadcast networks +	 may receive copies of their own multicasts immediately.  If a +	 router processes its own output as new input, confusion is likely, +	 and such datagrams must be ignored. */ +	if (ripng_lladdr_check(ifp, &from->sin6_addr)) { +		zlog_warn( +			"RIPng packet comes from my own link local address %s", +			inet6_ntoa(from->sin6_addr)); +		ripng_peer_bad_packet(from); +		return; +	} -	    if (IS_RIPNG_DEBUG_EVENT) { -	      struct prefix_ipv6 *p = (struct prefix_ipv6 *) &rp->p; +	/* As an additional check, periodic advertisements must have their +	 hop counts set to 255, and inbound, multicast packets sent from the +	 RIPng port (i.e. periodic advertisement or triggered update +	 packets) must be examined to ensure that the hop count is 255. */ +	if (hoplimit >= 0 && hoplimit != 255) { +		zlog_warn( +			"RIPng packet comes with non 255 hop count %d from %s", +			hoplimit, inet6_ntoa(from->sin6_addr)); +		ripng_peer_bad_packet(from); +		return; +	} -	      zlog_debug ("Poisone %s/%d on the interface %s [withdraw]", -                          inet6_ntoa(p->prefix), p->prefixlen, -                          ifindex2ifname(rinfo->ifindex, VRF_DEFAULT)); -	    } +	/* Update RIPng peer. */ +	ripng_peer_update(from, packet->version); -	    ripng_event (RIPNG_TRIGGERED_UPDATE, 0); -	  } -      } -} +	/* Reset nexthop. */ +	memset(&nexthop, 0, sizeof(struct ripng_nexthop)); +	nexthop.flag = RIPNG_NEXTHOP_UNSPEC; -/* RIP routing information. */ -static void -ripng_response_process (struct ripng_packet *packet, int size,  -			struct sockaddr_in6 *from, struct interface *ifp, -			int hoplimit) -{ -  caddr_t lim; -  struct rte *rte; -  struct ripng_nexthop nexthop; - -  /* RFC2080 2.4.2  Response Messages: -   The Response must be ignored if it is not from the RIPng port.  */ -  if (ntohs (from->sin6_port) != RIPNG_PORT_DEFAULT) -    { -      zlog_warn ("RIPng packet comes from non RIPng port %d from %s", -		 ntohs (from->sin6_port), inet6_ntoa (from->sin6_addr)); -      ripng_peer_bad_packet (from); -      return; -    } +	/* Set RTE pointer. */ +	rte = packet->rte; -  /* The datagram's IPv6 source address should be checked to see -   whether the datagram is from a valid neighbor; the source of the -   datagram must be a link-local address.  */ -  if (! IN6_IS_ADDR_LINKLOCAL(&from->sin6_addr)) -   { -      zlog_warn ("RIPng packet comes from non link local address %s", -		 inet6_ntoa (from->sin6_addr)); -      ripng_peer_bad_packet (from); -      return; -    } +	for (lim = ((caddr_t)packet) + size; (caddr_t)rte < lim; rte++) { +		/* First of all, we have to check this RTE is next hop RTE or +		   not.  Next hop RTE is completely different with normal RTE so +		   we need special treatment. */ +		if (rte->metric == RIPNG_METRIC_NEXTHOP) { +			ripng_nexthop_rte(rte, from, &nexthop); +			continue; +		} -  /* It is also worth checking to see whether the response is from one -   of the router's own addresses.  Interfaces on broadcast networks -   may receive copies of their own multicasts immediately.  If a -   router processes its own output as new input, confusion is likely, -   and such datagrams must be ignored. */ -  if (ripng_lladdr_check (ifp, &from->sin6_addr)) -    { -      zlog_warn ("RIPng packet comes from my own link local address %s", -		 inet6_ntoa (from->sin6_addr)); -      ripng_peer_bad_packet (from); -      return; -    } +		/* RTE information validation. */ + +		/* - is the destination prefix valid (e.g., not a multicast +		   prefix and not a link-local address) A link-local address +		   should never be present in an RTE. */ +		if (IN6_IS_ADDR_MULTICAST(&rte->addr)) { +			zlog_warn( +				"Destination prefix is a multicast address %s/%d [%d]", +				inet6_ntoa(rte->addr), rte->prefixlen, +				rte->metric); +			ripng_peer_bad_route(from); +			continue; +		} +		if (IN6_IS_ADDR_LINKLOCAL(&rte->addr)) { +			zlog_warn( +				"Destination prefix is a link-local address %s/%d [%d]", +				inet6_ntoa(rte->addr), rte->prefixlen, +				rte->metric); +			ripng_peer_bad_route(from); +			continue; +		} +		if (IN6_IS_ADDR_LOOPBACK(&rte->addr)) { +			zlog_warn( +				"Destination prefix is a loopback address %s/%d [%d]", +				inet6_ntoa(rte->addr), rte->prefixlen, +				rte->metric); +			ripng_peer_bad_route(from); +			continue; +		} -  /* As an additional check, periodic advertisements must have their -   hop counts set to 255, and inbound, multicast packets sent from the -   RIPng port (i.e. periodic advertisement or triggered update -   packets) must be examined to ensure that the hop count is 255. */ -  if (hoplimit >= 0 && hoplimit != 255) -    { -      zlog_warn ("RIPng packet comes with non 255 hop count %d from %s", -		 hoplimit, inet6_ntoa (from->sin6_addr)); -      ripng_peer_bad_packet (from); -      return; -    } +		/* - is the prefix length valid (i.e., between 0 and 128, +		   inclusive) */ +		if (rte->prefixlen > 128) { +			zlog_warn("Invalid prefix length %s/%d from %s%%%s", +				  inet6_ntoa(rte->addr), rte->prefixlen, +				  inet6_ntoa(from->sin6_addr), ifp->name); +			ripng_peer_bad_route(from); +			continue; +		} -  /* Update RIPng peer. */ -  ripng_peer_update (from, packet->version); -   -  /* Reset nexthop. */ -  memset (&nexthop, 0, sizeof (struct ripng_nexthop)); -  nexthop.flag = RIPNG_NEXTHOP_UNSPEC; +		/* - is the metric valid (i.e., between 1 and 16, inclusive) */ +		if (!(rte->metric >= 1 && rte->metric <= 16)) { +			zlog_warn("Invalid metric %d from %s%%%s", rte->metric, +				  inet6_ntoa(from->sin6_addr), ifp->name); +			ripng_peer_bad_route(from); +			continue; +		} -  /* Set RTE pointer. */ -  rte = packet->rte; +		/* Vincent: XXX Should we compute the direclty reachable nexthop +		 * for our RIPng network ? +		 **/ -  for (lim = ((caddr_t) packet) + size; (caddr_t) rte < lim; rte++)  -    { -      /* First of all, we have to check this RTE is next hop RTE or -         not.  Next hop RTE is completely different with normal RTE so -         we need special treatment. */ -      if (rte->metric == RIPNG_METRIC_NEXTHOP) -	{ -	  ripng_nexthop_rte (rte, from, &nexthop); -	  continue; -	} - -      /* RTE information validation. */ - -      /* - is the destination prefix valid (e.g., not a multicast -         prefix and not a link-local address) A link-local address -         should never be present in an RTE. */ -      if (IN6_IS_ADDR_MULTICAST (&rte->addr)) -	{ -	  zlog_warn ("Destination prefix is a multicast address %s/%d [%d]", -		     inet6_ntoa (rte->addr), rte->prefixlen, rte->metric); -	  ripng_peer_bad_route (from); -	  continue; -	} -      if (IN6_IS_ADDR_LINKLOCAL (&rte->addr)) -	{ -	  zlog_warn ("Destination prefix is a link-local address %s/%d [%d]", -		     inet6_ntoa (rte->addr), rte->prefixlen, rte->metric); -	  ripng_peer_bad_route (from); -	  continue; -	} -      if (IN6_IS_ADDR_LOOPBACK (&rte->addr)) -	{ -	  zlog_warn ("Destination prefix is a loopback address %s/%d [%d]", -		     inet6_ntoa (rte->addr), rte->prefixlen, rte->metric); -	  ripng_peer_bad_route (from); -	  continue; -	} - -      /* - is the prefix length valid (i.e., between 0 and 128, -         inclusive) */ -      if (rte->prefixlen > 128) -	{ -	  zlog_warn ("Invalid prefix length %s/%d from %s%%%s", -		     inet6_ntoa (rte->addr), rte->prefixlen, -		     inet6_ntoa (from->sin6_addr), ifp->name); -	  ripng_peer_bad_route (from); -	  continue; -	} - -      /* - is the metric valid (i.e., between 1 and 16, inclusive) */ -      if (! (rte->metric >= 1 && rte->metric <= 16)) -	{ -	  zlog_warn ("Invalid metric %d from %s%%%s", rte->metric, -		     inet6_ntoa (from->sin6_addr), ifp->name); -	  ripng_peer_bad_route (from); -	  continue; -	} - -      /* Vincent: XXX Should we compute the direclty reachable nexthop -       * for our RIPng network ? -       **/ - -      /* Routing table updates. */ -      ripng_route_process (rte, from, &nexthop, ifp); -    } +		/* Routing table updates. */ +		ripng_route_process(rte, from, &nexthop, ifp); +	}  }  /* Response to request message. */ -static void -ripng_request_process (struct ripng_packet *packet,int size,  -		       struct sockaddr_in6 *from, struct interface *ifp) -{ -  caddr_t lim; -  struct rte *rte; -  struct prefix_ipv6 p; -  struct route_node *rp; -  struct ripng_info *rinfo; -  struct ripng_interface *ri; - -  /* Does not reponse to the requests on the loopback interfaces */ -  if (if_is_loopback (ifp)) -    return; - -  /* Check RIPng process is enabled on this interface. */ -  ri = ifp->info; -  if (! ri->running) -    return; - -  /* When passive interface is specified, suppress responses */ -  if (ri->passive) -    return; - -  /* RIPng peer update. */ -  ripng_peer_update (from, packet->version); - -  lim = ((caddr_t) packet) + size; -  rte = packet->rte; - -  /* The Request is processed entry by entry.  If there are no -     entries, no response is given. */ -  if (lim == (caddr_t) rte) -    return; - -  /* There is one special case.  If there is exactly one entry in the -     request, and it has a destination prefix of zero, a prefix length -     of zero, and a metric of infinity (i.e., 16), then this is a -     request to send the entire routing table.  In that case, a call -     is made to the output process to send the routing table to the -     requesting address/port. */ -  if (lim == ((caddr_t) (rte + 1)) && -      IN6_IS_ADDR_UNSPECIFIED (&rte->addr) && -      rte->prefixlen == 0 && -      rte->metric == RIPNG_METRIC_INFINITY) -    {	 -      /* All route with split horizon */ -      ripng_output_process (ifp, from, ripng_all_route); -    } -  else -    { -      /* Except for this special case, processing is quite simple. -	 Examine the list of RTEs in the Request one by one.  For each -	 entry, look up the destination in the router's routing -	 database and, if there is a route, put that route's metric in -	 the metric field of the RTE.  If there is no explicit route -	 to the specified destination, put infinity in the metric -	 field.  Once all the entries have been filled in, change the -	 command from Request to Response and send the datagram back -	 to the requestor. */ -      memset (&p, 0, sizeof (struct prefix_ipv6)); -      p.family = AF_INET6; - -      for (; ((caddr_t) rte) < lim; rte++) -	{ -	  p.prefix = rte->addr; -	  p.prefixlen = rte->prefixlen; -	  apply_mask_ipv6 (&p); -	   -	  rp = route_node_lookup (ripng->table, (struct prefix *) &p); - -	  if (rp) -	    { -	      rinfo = listgetdata (listhead ((struct list *)rp->info)); -	      rte->metric = rinfo->metric; -	      route_unlock_node (rp); -	    } -	  else -	    rte->metric = RIPNG_METRIC_INFINITY; -	} -      packet->command = RIPNG_RESPONSE; - -      ripng_send_packet ((caddr_t) packet, size, from, ifp); -    } +static void ripng_request_process(struct ripng_packet *packet, int size, +				  struct sockaddr_in6 *from, +				  struct interface *ifp) +{ +	caddr_t lim; +	struct rte *rte; +	struct prefix_ipv6 p; +	struct route_node *rp; +	struct ripng_info *rinfo; +	struct ripng_interface *ri; + +	/* Does not reponse to the requests on the loopback interfaces */ +	if (if_is_loopback(ifp)) +		return; + +	/* Check RIPng process is enabled on this interface. */ +	ri = ifp->info; +	if (!ri->running) +		return; + +	/* When passive interface is specified, suppress responses */ +	if (ri->passive) +		return; + +	/* RIPng peer update. */ +	ripng_peer_update(from, packet->version); + +	lim = ((caddr_t)packet) + size; +	rte = packet->rte; + +	/* The Request is processed entry by entry.  If there are no +	   entries, no response is given. */ +	if (lim == (caddr_t)rte) +		return; + +	/* There is one special case.  If there is exactly one entry in the +	   request, and it has a destination prefix of zero, a prefix length +	   of zero, and a metric of infinity (i.e., 16), then this is a +	   request to send the entire routing table.  In that case, a call +	   is made to the output process to send the routing table to the +	   requesting address/port. */ +	if (lim == ((caddr_t)(rte + 1)) && IN6_IS_ADDR_UNSPECIFIED(&rte->addr) +	    && rte->prefixlen == 0 && rte->metric == RIPNG_METRIC_INFINITY) { +		/* All route with split horizon */ +		ripng_output_process(ifp, from, ripng_all_route); +	} else { +		/* Except for this special case, processing is quite simple. +		   Examine the list of RTEs in the Request one by one.  For each +		   entry, look up the destination in the router's routing +		   database and, if there is a route, put that route's metric in +		   the metric field of the RTE.  If there is no explicit route +		   to the specified destination, put infinity in the metric +		   field.  Once all the entries have been filled in, change the +		   command from Request to Response and send the datagram back +		   to the requestor. */ +		memset(&p, 0, sizeof(struct prefix_ipv6)); +		p.family = AF_INET6; + +		for (; ((caddr_t)rte) < lim; rte++) { +			p.prefix = rte->addr; +			p.prefixlen = rte->prefixlen; +			apply_mask_ipv6(&p); + +			rp = route_node_lookup(ripng->table, +					       (struct prefix *)&p); + +			if (rp) { +				rinfo = listgetdata( +					listhead((struct list *)rp->info)); +				rte->metric = rinfo->metric; +				route_unlock_node(rp); +			} else +				rte->metric = RIPNG_METRIC_INFINITY; +		} +		packet->command = RIPNG_RESPONSE; + +		ripng_send_packet((caddr_t)packet, size, from, ifp); +	}  }  /* First entry point of reading RIPng packet. */ -static int -ripng_read (struct thread *thread) -{ -  int len; -  int sock; -  struct sockaddr_in6 from; -  struct ripng_packet *packet; -  ifindex_t ifindex = 0; -  struct interface *ifp; -  int hoplimit = -1; - -  /* Check ripng is active and alive. */ -  assert (ripng != NULL); -  assert (ripng->sock >= 0); - -  /* Fetch thread data and set read pointer to empty for event -     managing.  `sock' sould be same as ripng->sock. */ -  sock = THREAD_FD (thread); -  ripng->t_read = NULL; - -  /* Add myself to the next event. */ -  ripng_event (RIPNG_READ, sock); - -  /* Read RIPng packet. */ -  len = ripng_recv_packet (sock, STREAM_DATA (ripng->ibuf),  -			   STREAM_SIZE (ripng->ibuf), &from, &ifindex, -			   &hoplimit); -  if (len < 0)  -    { -      zlog_warn ("RIPng recvfrom failed: %s.", safe_strerror (errno)); -      return len; -    } +static int ripng_read(struct thread *thread) +{ +	int len; +	int sock; +	struct sockaddr_in6 from; +	struct ripng_packet *packet; +	ifindex_t ifindex = 0; +	struct interface *ifp; +	int hoplimit = -1; + +	/* Check ripng is active and alive. */ +	assert(ripng != NULL); +	assert(ripng->sock >= 0); + +	/* Fetch thread data and set read pointer to empty for event +	   managing.  `sock' sould be same as ripng->sock. */ +	sock = THREAD_FD(thread); +	ripng->t_read = NULL; + +	/* Add myself to the next event. */ +	ripng_event(RIPNG_READ, sock); + +	/* Read RIPng packet. */ +	len = ripng_recv_packet(sock, STREAM_DATA(ripng->ibuf), +				STREAM_SIZE(ripng->ibuf), &from, &ifindex, +				&hoplimit); +	if (len < 0) { +		zlog_warn("RIPng recvfrom failed: %s.", safe_strerror(errno)); +		return len; +	} -  /* Check RTE boundary.  RTE size (Packet length - RIPng header size -     (4)) must be multiple size of one RTE size (20). */ -  if (((len - 4) % 20) != 0) -    { -      zlog_warn ("RIPng invalid packet size %d from %s", len, -		 inet6_ntoa (from.sin6_addr)); -      ripng_peer_bad_packet (&from); -      return 0; -    } +	/* Check RTE boundary.  RTE size (Packet length - RIPng header size +	   (4)) must be multiple size of one RTE size (20). */ +	if (((len - 4) % 20) != 0) { +		zlog_warn("RIPng invalid packet size %d from %s", len, +			  inet6_ntoa(from.sin6_addr)); +		ripng_peer_bad_packet(&from); +		return 0; +	} -  packet = (struct ripng_packet *) STREAM_DATA (ripng->ibuf); -  ifp = if_lookup_by_index (ifindex, VRF_DEFAULT); +	packet = (struct ripng_packet *)STREAM_DATA(ripng->ibuf); +	ifp = if_lookup_by_index(ifindex, VRF_DEFAULT); -  /* RIPng packet received. */ -  if (IS_RIPNG_DEBUG_EVENT) -    zlog_debug ("RIPng packet received from %s port %d on %s", -	       inet6_ntoa (from.sin6_addr), ntohs (from.sin6_port),  -	       ifp ? ifp->name : "unknown"); +	/* RIPng packet received. */ +	if (IS_RIPNG_DEBUG_EVENT) +		zlog_debug("RIPng packet received from %s port %d on %s", +			   inet6_ntoa(from.sin6_addr), ntohs(from.sin6_port), +			   ifp ? ifp->name : "unknown"); -  /* Logging before packet checking. */ -  if (IS_RIPNG_DEBUG_RECV) -    ripng_packet_dump (packet, len, "RECV"); +	/* Logging before packet checking. */ +	if (IS_RIPNG_DEBUG_RECV) +		ripng_packet_dump(packet, len, "RECV"); -  /* Packet comes from unknown interface. */ -  if (ifp == NULL) -    { -      zlog_warn ("RIPng packet comes from unknown interface %d", ifindex); -      return 0; -    } +	/* Packet comes from unknown interface. */ +	if (ifp == NULL) { +		zlog_warn("RIPng packet comes from unknown interface %d", +			  ifindex); +		return 0; +	} -  /* Packet version mismatch checking. */ -  if (packet->version != ripng->version)  -    { -      zlog_warn ("RIPng packet version %d doesn't fit to my version %d",  -		 packet->version, ripng->version); -      ripng_peer_bad_packet (&from); -      return 0; -    } +	/* Packet version mismatch checking. */ +	if (packet->version != ripng->version) { +		zlog_warn( +			"RIPng packet version %d doesn't fit to my version %d", +			packet->version, ripng->version); +		ripng_peer_bad_packet(&from); +		return 0; +	} -  /* Process RIPng packet. */ -  switch (packet->command) -    { -    case RIPNG_REQUEST: -      ripng_request_process (packet, len, &from, ifp); -      break; -    case RIPNG_RESPONSE: -      ripng_response_process (packet, len, &from, ifp, hoplimit); -      break; -    default: -      zlog_warn ("Invalid RIPng command %d", packet->command); -      ripng_peer_bad_packet (&from); -      break; -    } -  return 0; +	/* Process RIPng packet. */ +	switch (packet->command) { +	case RIPNG_REQUEST: +		ripng_request_process(packet, len, &from, ifp); +		break; +	case RIPNG_RESPONSE: +		ripng_response_process(packet, len, &from, ifp, hoplimit); +		break; +	default: +		zlog_warn("Invalid RIPng command %d", packet->command); +		ripng_peer_bad_packet(&from); +		break; +	} +	return 0;  }  /* Walk down the RIPng routing table then clear changed flag. */ -static void -ripng_clear_changed_flag (void) +static void ripng_clear_changed_flag(void)  { -  struct route_node *rp; -  struct ripng_info *rinfo = NULL; -  struct list *list = NULL; -  struct listnode *listnode = NULL; +	struct route_node *rp; +	struct ripng_info *rinfo = NULL; +	struct list *list = NULL; +	struct listnode *listnode = NULL; -  for (rp = route_top (ripng->table); rp; rp = route_next (rp)) -    if ((list = rp->info) != NULL) -      for (ALL_LIST_ELEMENTS_RO (list, listnode, rinfo)) -        { -          UNSET_FLAG (rinfo->flags, RIPNG_RTF_CHANGED); -          /* This flag can be set only on the first entry. */ -          break; -        } +	for (rp = route_top(ripng->table); rp; rp = route_next(rp)) +		if ((list = rp->info) != NULL) +			for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) { +				UNSET_FLAG(rinfo->flags, RIPNG_RTF_CHANGED); +				/* This flag can be set only on the first entry. +				 */ +				break; +			}  }  /* Regular update of RIPng route.  Send all routing formation to RIPng     enabled interface. */ -static int -ripng_update (struct thread *t) +static int ripng_update(struct thread *t)  { -  struct listnode *node; -  struct interface *ifp; -  struct ripng_interface *ri; +	struct listnode *node; +	struct interface *ifp; +	struct ripng_interface *ri; -  /* Clear update timer thread. */ -  ripng->t_update = NULL; +	/* Clear update timer thread. */ +	ripng->t_update = NULL; -  /* Logging update event. */ -  if (IS_RIPNG_DEBUG_EVENT) -    zlog_debug ("RIPng update timer expired!"); +	/* Logging update event. */ +	if (IS_RIPNG_DEBUG_EVENT) +		zlog_debug("RIPng update timer expired!"); -  /* Supply routes to each interface. */ -  for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) -    { -      ri = ifp->info; +	/* Supply routes to each interface. */ +	for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) { +		ri = ifp->info; -      if (if_is_loopback (ifp) || ! if_is_up (ifp)) -	continue; +		if (if_is_loopback(ifp) || !if_is_up(ifp)) +			continue; -      if (! ri->running) -	continue; +		if (!ri->running) +			continue; -      /* When passive interface is specified, suppress announce to the -         interface. */ -      if (ri->passive) -	continue; +		/* When passive interface is specified, suppress announce to the +		   interface. */ +		if (ri->passive) +			continue;  #if RIPNG_ADVANCED -      if (ri->ri_send == RIPNG_SEND_OFF) -	{ -	  if (IS_RIPNG_DEBUG_EVENT) -	    zlog_debug ("[Event] RIPng send to if %d is suppressed by config", -		 ifp->ifindex); -	  continue; -	} +		if (ri->ri_send == RIPNG_SEND_OFF) { +			if (IS_RIPNG_DEBUG_EVENT) +				zlog_debug( +					"[Event] RIPng send to if %d is suppressed by config", +					ifp->ifindex); +			continue; +		}  #endif /* RIPNG_ADVANCED */ -      ripng_output_process (ifp, NULL, ripng_all_route); -    } +		ripng_output_process(ifp, NULL, ripng_all_route); +	} -  /* Triggered updates may be suppressed if a regular update is due by -     the time the triggered update would be sent. */ -  if (ripng->t_triggered_interval) -    { -      thread_cancel (ripng->t_triggered_interval); -      ripng->t_triggered_interval = NULL; -    } -  ripng->trigger = 0; +	/* Triggered updates may be suppressed if a regular update is due by +	   the time the triggered update would be sent. */ +	if (ripng->t_triggered_interval) { +		thread_cancel(ripng->t_triggered_interval); +		ripng->t_triggered_interval = NULL; +	} +	ripng->trigger = 0; -  /* Reset flush event. */ -  ripng_event (RIPNG_UPDATE_EVENT, 0); +	/* Reset flush event. */ +	ripng_event(RIPNG_UPDATE_EVENT, 0); -  return 0; +	return 0;  }  /* Triggered update interval timer. */ -static int -ripng_triggered_interval (struct thread *t) +static int ripng_triggered_interval(struct thread *t)  { -  ripng->t_triggered_interval = NULL; +	ripng->t_triggered_interval = NULL; -  if (ripng->trigger) -    { -      ripng->trigger = 0; -      ripng_triggered_update (t); -    } -  return 0; -}      +	if (ripng->trigger) { +		ripng->trigger = 0; +		ripng_triggered_update(t); +	} +	return 0; +}  /* Execute triggered update. */ -int -ripng_triggered_update (struct thread *t) +int ripng_triggered_update(struct thread *t)  { -  struct listnode *node; -  struct interface *ifp; -  struct ripng_interface *ri; -  int interval; +	struct listnode *node; +	struct interface *ifp; +	struct ripng_interface *ri; +	int interval; -  ripng->t_triggered_update = NULL; +	ripng->t_triggered_update = NULL; -  /* Cancel interval timer. */ -  if (ripng->t_triggered_interval) -    { -      thread_cancel (ripng->t_triggered_interval); -      ripng->t_triggered_interval = NULL; -    } -  ripng->trigger = 0; +	/* Cancel interval timer. */ +	if (ripng->t_triggered_interval) { +		thread_cancel(ripng->t_triggered_interval); +		ripng->t_triggered_interval = NULL; +	} +	ripng->trigger = 0; -  /* Logging triggered update. */ -  if (IS_RIPNG_DEBUG_EVENT) -    zlog_debug ("RIPng triggered update!"); +	/* Logging triggered update. */ +	if (IS_RIPNG_DEBUG_EVENT) +		zlog_debug("RIPng triggered update!"); -  /* Split Horizon processing is done when generating triggered -     updates as well as normal updates (see section 2.6). */ -  for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) -    { -      ri = ifp->info; +	/* Split Horizon processing is done when generating triggered +	   updates as well as normal updates (see section 2.6). */ +	for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) { +		ri = ifp->info; -      if (if_is_loopback (ifp) || ! if_is_up (ifp)) -	continue; +		if (if_is_loopback(ifp) || !if_is_up(ifp)) +			continue; -      if (! ri->running) -	continue; +		if (!ri->running) +			continue; -      /* When passive interface is specified, suppress announce to the -         interface. */ -      if (ri->passive) -	continue; +		/* When passive interface is specified, suppress announce to the +		   interface. */ +		if (ri->passive) +			continue; -      ripng_output_process (ifp, NULL, ripng_changed_route); -    } +		ripng_output_process(ifp, NULL, ripng_changed_route); +	} -  /* Once all of the triggered updates have been generated, the route -     change flags should be cleared. */ -  ripng_clear_changed_flag (); +	/* Once all of the triggered updates have been generated, the route +	   change flags should be cleared. */ +	ripng_clear_changed_flag(); -  /* After a triggered update is sent, a timer should be set for a -     random interval between 1 and 5 seconds.  If other changes that -     would trigger updates occur before the timer expires, a single -     update is triggered when the timer expires. */ -  interval = (random () % 5) + 1; +	/* After a triggered update is sent, a timer should be set for a +	   random interval between 1 and 5 seconds.  If other changes that +	   would trigger updates occur before the timer expires, a single +	   update is triggered when the timer expires. */ +	interval = (random() % 5) + 1; -  ripng->t_triggered_interval = NULL; -  thread_add_timer(master, ripng_triggered_interval, NULL, interval, -                   &ripng->t_triggered_interval); +	ripng->t_triggered_interval = NULL; +	thread_add_timer(master, ripng_triggered_interval, NULL, interval, +			 &ripng->t_triggered_interval); -  return 0; +	return 0;  }  /* Write routing table entry to the stream and return next index of     the routing table entry in the stream. */ -int -ripng_write_rte (int num, struct stream *s, struct prefix_ipv6 *p, -		 struct in6_addr *nexthop, u_int16_t tag, u_char metric) -{ -  /* RIPng packet header. */ -  if (num == 0) -    { -      stream_putc (s, RIPNG_RESPONSE); -      stream_putc (s, RIPNG_V1); -      stream_putw (s, 0); -    } +int ripng_write_rte(int num, struct stream *s, struct prefix_ipv6 *p, +		    struct in6_addr *nexthop, u_int16_t tag, u_char metric) +{ +	/* RIPng packet header. */ +	if (num == 0) { +		stream_putc(s, RIPNG_RESPONSE); +		stream_putc(s, RIPNG_V1); +		stream_putw(s, 0); +	} -  /* Write routing table entry. */ -  if (!nexthop) -    stream_write (s, (u_char *) &p->prefix, sizeof (struct in6_addr)); -  else -    stream_write (s, (u_char *) nexthop, sizeof (struct in6_addr)); -  stream_putw (s, tag); -  if (p) -    stream_putc (s, p->prefixlen); -  else -    stream_putc (s, 0); -  stream_putc (s, metric); +	/* Write routing table entry. */ +	if (!nexthop) +		stream_write(s, (u_char *)&p->prefix, sizeof(struct in6_addr)); +	else +		stream_write(s, (u_char *)nexthop, sizeof(struct in6_addr)); +	stream_putw(s, tag); +	if (p) +		stream_putc(s, p->prefixlen); +	else +		stream_putc(s, 0); +	stream_putc(s, metric); -  return ++num; +	return ++num;  }  /* Send RESPONSE message to specified destination. */ -void -ripng_output_process (struct interface *ifp, struct sockaddr_in6 *to, -		      int route_type) -{ -  int ret; -  struct route_node *rp; -  struct ripng_info *rinfo; -  struct ripng_interface *ri; -  struct ripng_aggregate *aggregate; -  struct prefix_ipv6 *p; -  struct list * ripng_rte_list; -  struct list *list = NULL; -  struct listnode *listnode = NULL; - -  if (IS_RIPNG_DEBUG_EVENT) { -    if (to) -      zlog_debug ("RIPng update routes to neighbor %s", -                 inet6_ntoa(to->sin6_addr)); -    else -      zlog_debug ("RIPng update routes on interface %s", ifp->name); -  } - -  /* Get RIPng interface. */ -  ri = ifp->info; -  -  ripng_rte_list = ripng_rte_new(); -  -  for (rp = route_top (ripng->table); rp; rp = route_next (rp)) -    { -      if ((list = rp->info) != NULL && -          (rinfo = listgetdata (listhead (list))) != NULL && -          rinfo->suppress == 0) -	{ -	  /* If no route-map are applied, the RTE will be these following -	   * informations. -	   */ -	  p = (struct prefix_ipv6 *) &rp->p; -	  rinfo->metric_out = rinfo->metric; -	  rinfo->tag_out    = rinfo->tag; -	  memset(&rinfo->nexthop_out, 0, sizeof(rinfo->nexthop_out)); -	  /* In order to avoid some local loops, -	   * if the RIPng route has a nexthop via this interface, keep the nexthop, -	   * otherwise set it to 0. The nexthop should not be propagated -	   * beyond the local broadcast/multicast area in order -	   * to avoid an IGP multi-level recursive look-up. -	   */ -	  if (rinfo->ifindex == ifp->ifindex) -	    rinfo->nexthop_out = rinfo->nexthop; - -	  /* Apply output filters. */ -	  ret = ripng_filter (RIPNG_FILTER_OUT, p, ri); -	  if (ret < 0) -	    continue; - -	  /* Changed route only output. */ -	  if (route_type == ripng_changed_route && -	      (! (rinfo->flags & RIPNG_RTF_CHANGED))) -	    continue; - -	  /* Split horizon. */ -	  if (ri->split_horizon == RIPNG_SPLIT_HORIZON) -	  { -	    /* We perform split horizon for RIPng routes. */ -	    int suppress = 0; -	    struct ripng_info *tmp_rinfo = NULL; - -	    for (ALL_LIST_ELEMENTS_RO (list, listnode, tmp_rinfo)) -	      if (tmp_rinfo->type == ZEBRA_ROUTE_RIPNG && -	          tmp_rinfo->ifindex == ifp->ifindex) -	        { -	          suppress = 1; -	          break; -	        } -	    if (suppress) -	      continue; -	  } - -	  /* Preparation for route-map. */ -	  rinfo->metric_set = 0; -	  /* nexthop_out, -	   * metric_out -	   * and tag_out are already initialized. -	   */ - -	  /* Interface route-map */ -	  if (ri->routemap[RIPNG_FILTER_OUT]) -	    { -	      int ret; - -	      ret = route_map_apply (ri->routemap[RIPNG_FILTER_OUT],  -				     (struct prefix *) p, RMAP_RIPNG,  -				     rinfo); - -	      if (ret == RMAP_DENYMATCH) -		{ -		  if (IS_RIPNG_DEBUG_PACKET) -		    zlog_debug ("RIPng %s/%d is filtered by route-map out", -			       inet6_ntoa (p->prefix), p->prefixlen); -		  continue; -		} - -	    } - -	  /* Redistribute route-map. */ -	  if (ripng->route_map[rinfo->type].name) -	    { -	      int ret; - -	      ret = route_map_apply (ripng->route_map[rinfo->type].map, -				     (struct prefix *) p, RMAP_RIPNG, -				     rinfo); +void ripng_output_process(struct interface *ifp, struct sockaddr_in6 *to, +			  int route_type) +{ +	int ret; +	struct route_node *rp; +	struct ripng_info *rinfo; +	struct ripng_interface *ri; +	struct ripng_aggregate *aggregate; +	struct prefix_ipv6 *p; +	struct list *ripng_rte_list; +	struct list *list = NULL; +	struct listnode *listnode = NULL; + +	if (IS_RIPNG_DEBUG_EVENT) { +		if (to) +			zlog_debug("RIPng update routes to neighbor %s", +				   inet6_ntoa(to->sin6_addr)); +		else +			zlog_debug("RIPng update routes on interface %s", +				   ifp->name); +	} -	      if (ret == RMAP_DENYMATCH) -		{ -		  if (IS_RIPNG_DEBUG_PACKET) -		    zlog_debug ("RIPng %s/%d is filtered by route-map", -			       inet6_ntoa (p->prefix), p->prefixlen); -		  continue; -		} -	    } - -	  /* When the route-map does not set metric. */ -	  if (! rinfo->metric_set) -	    { -	      /* If the redistribute metric is set. */ -	      if (ripng->route_map[rinfo->type].metric_config -		  && rinfo->metric != RIPNG_METRIC_INFINITY) -		{ -		  rinfo->metric_out = ripng->route_map[rinfo->type].metric; -		} -	      else -		{ -		  /* If the route is not connected or localy generated -		     one, use default-metric value */ -		  if (rinfo->type != ZEBRA_ROUTE_RIPNG -		      && rinfo->type != ZEBRA_ROUTE_CONNECT -		      && rinfo->metric != RIPNG_METRIC_INFINITY) -		    rinfo->metric_out = ripng->default_metric; +	/* Get RIPng interface. */ +	ri = ifp->info; + +	ripng_rte_list = ripng_rte_new(); + +	for (rp = route_top(ripng->table); rp; rp = route_next(rp)) { +		if ((list = rp->info) != NULL +		    && (rinfo = listgetdata(listhead(list))) != NULL +		    && rinfo->suppress == 0) { +			/* If no route-map are applied, the RTE will be these +			 * following +			 * informations. +			 */ +			p = (struct prefix_ipv6 *)&rp->p; +			rinfo->metric_out = rinfo->metric; +			rinfo->tag_out = rinfo->tag; +			memset(&rinfo->nexthop_out, 0, +			       sizeof(rinfo->nexthop_out)); +			/* In order to avoid some local loops, +			 * if the RIPng route has a nexthop via this interface, +			 * keep the nexthop, +			 * otherwise set it to 0. The nexthop should not be +			 * propagated +			 * beyond the local broadcast/multicast area in order +			 * to avoid an IGP multi-level recursive look-up. +			 */ +			if (rinfo->ifindex == ifp->ifindex) +				rinfo->nexthop_out = rinfo->nexthop; + +			/* Apply output filters. */ +			ret = ripng_filter(RIPNG_FILTER_OUT, p, ri); +			if (ret < 0) +				continue; + +			/* Changed route only output. */ +			if (route_type == ripng_changed_route +			    && (!(rinfo->flags & RIPNG_RTF_CHANGED))) +				continue; + +			/* Split horizon. */ +			if (ri->split_horizon == RIPNG_SPLIT_HORIZON) { +				/* We perform split horizon for RIPng routes. */ +				int suppress = 0; +				struct ripng_info *tmp_rinfo = NULL; + +				for (ALL_LIST_ELEMENTS_RO(list, listnode, +							  tmp_rinfo)) +					if (tmp_rinfo->type == ZEBRA_ROUTE_RIPNG +					    && tmp_rinfo->ifindex +						       == ifp->ifindex) { +						suppress = 1; +						break; +					} +				if (suppress) +					continue; +			} + +			/* Preparation for route-map. */ +			rinfo->metric_set = 0; +			/* nexthop_out, +			 * metric_out +			 * and tag_out are already initialized. +			 */ + +			/* Interface route-map */ +			if (ri->routemap[RIPNG_FILTER_OUT]) { +				int ret; + +				ret = route_map_apply( +					ri->routemap[RIPNG_FILTER_OUT], +					(struct prefix *)p, RMAP_RIPNG, rinfo); + +				if (ret == RMAP_DENYMATCH) { +					if (IS_RIPNG_DEBUG_PACKET) +						zlog_debug( +							"RIPng %s/%d is filtered by route-map out", +							inet6_ntoa(p->prefix), +							p->prefixlen); +					continue; +				} +			} + +			/* Redistribute route-map. */ +			if (ripng->route_map[rinfo->type].name) { +				int ret; + +				ret = route_map_apply( +					ripng->route_map[rinfo->type].map, +					(struct prefix *)p, RMAP_RIPNG, rinfo); + +				if (ret == RMAP_DENYMATCH) { +					if (IS_RIPNG_DEBUG_PACKET) +						zlog_debug( +							"RIPng %s/%d is filtered by route-map", +							inet6_ntoa(p->prefix), +							p->prefixlen); +					continue; +				} +			} + +			/* When the route-map does not set metric. */ +			if (!rinfo->metric_set) { +				/* If the redistribute metric is set. */ +				if (ripng->route_map[rinfo->type].metric_config +				    && rinfo->metric != RIPNG_METRIC_INFINITY) { +					rinfo->metric_out = +						ripng->route_map[rinfo->type] +							.metric; +				} else { +					/* If the route is not connected or +					   localy generated +					   one, use default-metric value */ +					if (rinfo->type != ZEBRA_ROUTE_RIPNG +					    && rinfo->type +						       != ZEBRA_ROUTE_CONNECT +					    && rinfo->metric +						       != RIPNG_METRIC_INFINITY) +						rinfo->metric_out = +							ripng->default_metric; +				} +			} + +			/* Apply offset-list */ +			if (rinfo->metric_out != RIPNG_METRIC_INFINITY) +				ripng_offset_list_apply_out(p, ifp, +							    &rinfo->metric_out); + +			if (rinfo->metric_out > RIPNG_METRIC_INFINITY) +				rinfo->metric_out = RIPNG_METRIC_INFINITY; + +			/* Perform split-horizon with poisoned reverse +			 * for RIPng routes. +			 **/ +			if (ri->split_horizon +			    == RIPNG_SPLIT_HORIZON_POISONED_REVERSE) { +				struct ripng_info *tmp_rinfo = NULL; + +				for (ALL_LIST_ELEMENTS_RO(list, listnode, +							  tmp_rinfo)) +					if ((tmp_rinfo->type +					     == ZEBRA_ROUTE_RIPNG) +					    && tmp_rinfo->ifindex +						       == ifp->ifindex) +						rinfo->metric_out = +							RIPNG_METRIC_INFINITY; +			} + +			/* Add RTE to the list */ +			ripng_rte_add(ripng_rte_list, p, rinfo, NULL);  		} -	    } - -          /* Apply offset-list */ -	  if (rinfo->metric_out != RIPNG_METRIC_INFINITY) -            ripng_offset_list_apply_out (p, ifp, &rinfo->metric_out); - -          if (rinfo->metric_out > RIPNG_METRIC_INFINITY) -            rinfo->metric_out = RIPNG_METRIC_INFINITY; - -	  /* Perform split-horizon with poisoned reverse  -	   * for RIPng routes. -	   **/ -	  if (ri->split_horizon == RIPNG_SPLIT_HORIZON_POISONED_REVERSE) { -	    struct ripng_info *tmp_rinfo = NULL; - -	    for (ALL_LIST_ELEMENTS_RO (list, listnode, tmp_rinfo)) -	      if ((tmp_rinfo->type == ZEBRA_ROUTE_RIPNG) && -	           tmp_rinfo->ifindex == ifp->ifindex) -	        rinfo->metric_out = RIPNG_METRIC_INFINITY; -	  } - -	  /* Add RTE to the list */ -	  ripng_rte_add(ripng_rte_list, p, rinfo, NULL); -	} - -      /* Process the aggregated RTE entry */ -      if ((aggregate = rp->aggregate) != NULL &&  -	  aggregate->count > 0 &&  -	  aggregate->suppress == 0) -	{ -	  /* If no route-map are applied, the RTE will be these following -	   * informations. -	   */ -	  p = (struct prefix_ipv6 *) &rp->p; -	  aggregate->metric_set = 0; -	  aggregate->metric_out = aggregate->metric; -	  aggregate->tag_out    = aggregate->tag; -	  memset(&aggregate->nexthop_out, 0, sizeof(aggregate->nexthop_out)); - -	  /* Apply output filters.*/ -	  ret = ripng_filter (RIPNG_FILTER_OUT, p, ri); -	  if (ret < 0) -	    continue; - -	  /* Interface route-map */ -	  if (ri->routemap[RIPNG_FILTER_OUT]) -	    { -	      int ret; -	      struct ripng_info newinfo; - -	      /* let's cast the aggregate structure to ripng_info */ -	      memset (&newinfo, 0, sizeof (struct ripng_info)); -	      /* the nexthop is :: */ -	      newinfo.metric = aggregate->metric; -	      newinfo.metric_out = aggregate->metric_out; -	      newinfo.tag = aggregate->tag; -	      newinfo.tag_out = aggregate->tag_out; - -	      ret = route_map_apply (ri->routemap[RIPNG_FILTER_OUT],  -				     (struct prefix *) p, RMAP_RIPNG,  -				     &newinfo); - -	      if (ret == RMAP_DENYMATCH) -		{ -		  if (IS_RIPNG_DEBUG_PACKET) -		    zlog_debug ("RIPng %s/%d is filtered by route-map out", -			       inet6_ntoa (p->prefix), p->prefixlen); -		  continue; -		} - -	      aggregate->metric_out = newinfo.metric_out; -	      aggregate->tag_out = newinfo.tag_out; -	      if (IN6_IS_ADDR_LINKLOCAL(&newinfo.nexthop_out)) -		aggregate->nexthop_out = newinfo.nexthop_out; -	    } - -	  /* There is no redistribute routemap for the aggregated RTE */ - -	  /* Changed route only output. */ -	  /* XXX, vincent, in order to increase time convergence, -	   * it should be announced if a child has changed. -	   */ -	  if (route_type == ripng_changed_route) -	    continue; - -	  /* Apply offset-list */ -	  if (aggregate->metric_out != RIPNG_METRIC_INFINITY) -	    ripng_offset_list_apply_out (p, ifp, &aggregate->metric_out); - -	  if (aggregate->metric_out > RIPNG_METRIC_INFINITY) -	    aggregate->metric_out = RIPNG_METRIC_INFINITY; -	  /* Add RTE to the list */ -	  ripng_rte_add(ripng_rte_list, p, NULL, aggregate); +		/* Process the aggregated RTE entry */ +		if ((aggregate = rp->aggregate) != NULL && aggregate->count > 0 +		    && aggregate->suppress == 0) { +			/* If no route-map are applied, the RTE will be these +			 * following +			 * informations. +			 */ +			p = (struct prefix_ipv6 *)&rp->p; +			aggregate->metric_set = 0; +			aggregate->metric_out = aggregate->metric; +			aggregate->tag_out = aggregate->tag; +			memset(&aggregate->nexthop_out, 0, +			       sizeof(aggregate->nexthop_out)); + +			/* Apply output filters.*/ +			ret = ripng_filter(RIPNG_FILTER_OUT, p, ri); +			if (ret < 0) +				continue; + +			/* Interface route-map */ +			if (ri->routemap[RIPNG_FILTER_OUT]) { +				int ret; +				struct ripng_info newinfo; + +				/* let's cast the aggregate structure to +				 * ripng_info */ +				memset(&newinfo, 0, sizeof(struct ripng_info)); +				/* the nexthop is :: */ +				newinfo.metric = aggregate->metric; +				newinfo.metric_out = aggregate->metric_out; +				newinfo.tag = aggregate->tag; +				newinfo.tag_out = aggregate->tag_out; + +				ret = route_map_apply( +					ri->routemap[RIPNG_FILTER_OUT], +					(struct prefix *)p, RMAP_RIPNG, +					&newinfo); + +				if (ret == RMAP_DENYMATCH) { +					if (IS_RIPNG_DEBUG_PACKET) +						zlog_debug( +							"RIPng %s/%d is filtered by route-map out", +							inet6_ntoa(p->prefix), +							p->prefixlen); +					continue; +				} + +				aggregate->metric_out = newinfo.metric_out; +				aggregate->tag_out = newinfo.tag_out; +				if (IN6_IS_ADDR_LINKLOCAL(&newinfo.nexthop_out)) +					aggregate->nexthop_out = +						newinfo.nexthop_out; +			} + +			/* There is no redistribute routemap for the aggregated +			 * RTE */ + +			/* Changed route only output. */ +			/* XXX, vincent, in order to increase time convergence, +			 * it should be announced if a child has changed. +			 */ +			if (route_type == ripng_changed_route) +				continue; + +			/* Apply offset-list */ +			if (aggregate->metric_out != RIPNG_METRIC_INFINITY) +				ripng_offset_list_apply_out( +					p, ifp, &aggregate->metric_out); + +			if (aggregate->metric_out > RIPNG_METRIC_INFINITY) +				aggregate->metric_out = RIPNG_METRIC_INFINITY; + +			/* Add RTE to the list */ +			ripng_rte_add(ripng_rte_list, p, NULL, aggregate); +		}  	} -    } - -  /* Flush the list */ -  ripng_rte_send(ripng_rte_list, ifp, to); -  ripng_rte_free(ripng_rte_list); +	/* Flush the list */ +	ripng_rte_send(ripng_rte_list, ifp, to); +	ripng_rte_free(ripng_rte_list);  }  /* Create new RIPng instance and set it to global variable. */ -static int -ripng_create (void) +static int ripng_create(void)  { -  /* ripng should be NULL. */ -  assert (ripng == NULL); +	/* ripng should be NULL. */ +	assert(ripng == NULL); -  /* Allocaste RIPng instance. */ -  ripng = XCALLOC (MTYPE_RIPNG, sizeof (struct ripng)); +	/* Allocaste RIPng instance. */ +	ripng = XCALLOC(MTYPE_RIPNG, sizeof(struct ripng)); -  /* Default version and timer values. */ -  ripng->version = RIPNG_V1; -  ripng->update_time = RIPNG_UPDATE_TIMER_DEFAULT; -  ripng->timeout_time = RIPNG_TIMEOUT_TIMER_DEFAULT; -  ripng->garbage_time = RIPNG_GARBAGE_TIMER_DEFAULT; -  ripng->default_metric = RIPNG_DEFAULT_METRIC_DEFAULT; -   -  /* Make buffer.  */ -  ripng->ibuf = stream_new (RIPNG_MAX_PACKET_SIZE * 5); -  ripng->obuf = stream_new (RIPNG_MAX_PACKET_SIZE); +	/* Default version and timer values. */ +	ripng->version = RIPNG_V1; +	ripng->update_time = RIPNG_UPDATE_TIMER_DEFAULT; +	ripng->timeout_time = RIPNG_TIMEOUT_TIMER_DEFAULT; +	ripng->garbage_time = RIPNG_GARBAGE_TIMER_DEFAULT; +	ripng->default_metric = RIPNG_DEFAULT_METRIC_DEFAULT; + +	/* Make buffer.  */ +	ripng->ibuf = stream_new(RIPNG_MAX_PACKET_SIZE * 5); +	ripng->obuf = stream_new(RIPNG_MAX_PACKET_SIZE); + +	/* Initialize RIPng routig table. */ +	ripng->table = route_table_init(); +	ripng->route = route_table_init(); +	ripng->aggregate = route_table_init(); -  /* Initialize RIPng routig table. */ -  ripng->table = route_table_init (); -  ripng->route = route_table_init (); -  ripng->aggregate = route_table_init (); -  -  /* Make socket. */ -  ripng->sock = ripng_make_socket (); -  if (ripng->sock < 0) -    return ripng->sock; +	/* Make socket. */ +	ripng->sock = ripng_make_socket(); +	if (ripng->sock < 0) +		return ripng->sock; -  /* Threads. */ -  ripng_event (RIPNG_READ, ripng->sock); -  ripng_event (RIPNG_UPDATE_EVENT, 1); +	/* Threads. */ +	ripng_event(RIPNG_READ, ripng->sock); +	ripng_event(RIPNG_UPDATE_EVENT, 1); -  return 0; +	return 0;  }  /* Send RIPng request to the interface. */ -int -ripng_request (struct interface *ifp) +int ripng_request(struct interface *ifp)  { -  struct rte *rte; -  struct ripng_packet ripng_packet; +	struct rte *rte; +	struct ripng_packet ripng_packet; -  /* In default ripd doesn't send RIP_REQUEST to the loopback interface. */ -  if (if_is_loopback(ifp)) -    return 0; +	/* In default ripd doesn't send RIP_REQUEST to the loopback interface. +	 */ +	if (if_is_loopback(ifp)) +		return 0; -  /* If interface is down, don't send RIP packet. */ -  if (! if_is_up (ifp)) -    return 0; +	/* If interface is down, don't send RIP packet. */ +	if (!if_is_up(ifp)) +		return 0; -  if (IS_RIPNG_DEBUG_EVENT) -    zlog_debug ("RIPng send request to %s", ifp->name); +	if (IS_RIPNG_DEBUG_EVENT) +		zlog_debug("RIPng send request to %s", ifp->name); -  memset (&ripng_packet, 0, sizeof (ripng_packet)); -  ripng_packet.command = RIPNG_REQUEST; -  ripng_packet.version = RIPNG_V1; -  rte = ripng_packet.rte; -  rte->metric = RIPNG_METRIC_INFINITY; +	memset(&ripng_packet, 0, sizeof(ripng_packet)); +	ripng_packet.command = RIPNG_REQUEST; +	ripng_packet.version = RIPNG_V1; +	rte = ripng_packet.rte; +	rte->metric = RIPNG_METRIC_INFINITY; -  return ripng_send_packet ((caddr_t) &ripng_packet, sizeof (ripng_packet),  -			    NULL, ifp); +	return ripng_send_packet((caddr_t)&ripng_packet, sizeof(ripng_packet), +				 NULL, ifp);  } -static int -ripng_update_jitter (int time) +static int ripng_update_jitter(int time)  { -  return ((random () % (time + 1)) - (time / 2)); +	return ((random() % (time + 1)) - (time / 2));  } -void -ripng_event (enum ripng_event event, int sock) +void ripng_event(enum ripng_event event, int sock)  { -  int jitter = 0; +	int jitter = 0; -  switch (event) -    { -    case RIPNG_READ: -      thread_add_read(master, ripng_read, NULL, sock, &ripng->t_read); -      break; -    case RIPNG_UPDATE_EVENT: -      if (ripng->t_update) -	{ -	  thread_cancel (ripng->t_update); -	  ripng->t_update = NULL; -	} -      /* Update timer jitter. */ -      jitter = ripng_update_jitter (ripng->update_time); - -      ripng->t_update = NULL; -      thread_add_timer(master, ripng_update, NULL, sock ? 2 : ripng->update_time + jitter, -                       &ripng->t_update); -      break; -    case RIPNG_TRIGGERED_UPDATE: -      if (ripng->t_triggered_interval) -	ripng->trigger = 1; -      else thread_add_event(master, ripng_triggered_update, NULL, 0, -                            &ripng->t_triggered_update); -      break; -    default: -      break; -    } +	switch (event) { +	case RIPNG_READ: +		thread_add_read(master, ripng_read, NULL, sock, &ripng->t_read); +		break; +	case RIPNG_UPDATE_EVENT: +		if (ripng->t_update) { +			thread_cancel(ripng->t_update); +			ripng->t_update = NULL; +		} +		/* Update timer jitter. */ +		jitter = ripng_update_jitter(ripng->update_time); + +		ripng->t_update = NULL; +		thread_add_timer(master, ripng_update, NULL, +				 sock ? 2 : ripng->update_time + jitter, +				 &ripng->t_update); +		break; +	case RIPNG_TRIGGERED_UPDATE: +		if (ripng->t_triggered_interval) +			ripng->trigger = 1; +		else +			thread_add_event(master, ripng_triggered_update, NULL, +					 0, &ripng->t_triggered_update); +		break; +	default: +		break; +	}  }  /* Print out routes update time. */ -static void -ripng_vty_out_uptime (struct vty *vty, struct ripng_info *rinfo) +static void ripng_vty_out_uptime(struct vty *vty, struct ripng_info *rinfo)  { -  time_t clock; -  struct tm *tm; +	time_t clock; +	struct tm *tm;  #define TIME_BUF 25 -  char timebuf [TIME_BUF]; -  struct thread *thread; -   -  if ((thread = rinfo->t_timeout) != NULL) -    { -      clock = thread_timer_remain_second (thread); -      tm = gmtime (&clock); -      strftime (timebuf, TIME_BUF, "%M:%S", tm); -      vty_out (vty, "%5s", timebuf); -    } -  else if ((thread = rinfo->t_garbage_collect) != NULL) -    { -      clock = thread_timer_remain_second (thread); -      tm = gmtime (&clock); -      strftime (timebuf, TIME_BUF, "%M:%S", tm); -      vty_out (vty, "%5s", timebuf); -    } +	char timebuf[TIME_BUF]; +	struct thread *thread; + +	if ((thread = rinfo->t_timeout) != NULL) { +		clock = thread_timer_remain_second(thread); +		tm = gmtime(&clock); +		strftime(timebuf, TIME_BUF, "%M:%S", tm); +		vty_out(vty, "%5s", timebuf); +	} else if ((thread = rinfo->t_garbage_collect) != NULL) { +		clock = thread_timer_remain_second(thread); +		tm = gmtime(&clock); +		strftime(timebuf, TIME_BUF, "%M:%S", tm); +		vty_out(vty, "%5s", timebuf); +	}  } -static char * -ripng_route_subtype_print (struct ripng_info *rinfo) -{ -  static char str[3]; -  memset(str, 0, 3); - -  if (rinfo->suppress) -    strcat(str, "S"); +static char *ripng_route_subtype_print(struct ripng_info *rinfo) +{ +	static char str[3]; +	memset(str, 0, 3); + +	if (rinfo->suppress) +		strcat(str, "S"); + +	switch (rinfo->sub_type) { +	case RIPNG_ROUTE_RTE: +		strcat(str, "n"); +		break; +	case RIPNG_ROUTE_STATIC: +		strcat(str, "s"); +		break; +	case RIPNG_ROUTE_DEFAULT: +		strcat(str, "d"); +		break; +	case RIPNG_ROUTE_REDISTRIBUTE: +		strcat(str, "r"); +		break; +	case RIPNG_ROUTE_INTERFACE: +		strcat(str, "i"); +		break; +	default: +		strcat(str, "?"); +		break; +	} -  switch (rinfo->sub_type) -    { -       case RIPNG_ROUTE_RTE: -         strcat(str, "n"); -         break; -       case RIPNG_ROUTE_STATIC: -         strcat(str, "s"); -         break; -       case RIPNG_ROUTE_DEFAULT: -         strcat(str, "d"); -         break; -       case RIPNG_ROUTE_REDISTRIBUTE: -         strcat(str, "r"); -         break; -       case RIPNG_ROUTE_INTERFACE: -         strcat(str, "i"); -         break; -       default: -         strcat(str, "?"); -         break; -    } -  -  return str; +	return str;  }  DEFUN (show_ipv6_ripng, @@ -1992,106 +1947,106 @@ DEFUN (show_ipv6_ripng,         IPV6_STR         "Show RIPng routes\n")  { -  struct route_node *rp; -  struct ripng_info *rinfo; -  struct ripng_aggregate *aggregate; -  struct prefix_ipv6 *p; -  struct list *list = NULL; -  struct listnode *listnode = NULL; -  int len; - -  if (! ripng) -    return CMD_SUCCESS; - -  /* Header of display. */  -  vty_out (vty, "Codes: R - RIPng, C - connected, S - Static, O - OSPF, B - BGP\n" -	   "Sub-codes:\n" -	   "      (n) - normal, (s) - static, (d) - default, (r) - redistribute,\n" -	   "      (i) - interface, (a/S) - aggregated/Suppressed\n\n" -	   "   Network      Next Hop                      Via     Metric Tag Time\n"); -   -  for (rp = route_top (ripng->table); rp; rp = route_next (rp)) -    { -      if ((aggregate = rp->aggregate) != NULL) -	{ -	  p = (struct prefix_ipv6 *) &rp->p; +	struct route_node *rp; +	struct ripng_info *rinfo; +	struct ripng_aggregate *aggregate; +	struct prefix_ipv6 *p; +	struct list *list = NULL; +	struct listnode *listnode = NULL; +	int len; + +	if (!ripng) +		return CMD_SUCCESS; + +	/* Header of display. */ +	vty_out(vty, +		"Codes: R - RIPng, C - connected, S - Static, O - OSPF, B - BGP\n" +		"Sub-codes:\n" +		"      (n) - normal, (s) - static, (d) - default, (r) - redistribute,\n" +		"      (i) - interface, (a/S) - aggregated/Suppressed\n\n" +		"   Network      Next Hop                      Via     Metric Tag Time\n"); + +	for (rp = route_top(ripng->table); rp; rp = route_next(rp)) { +		if ((aggregate = rp->aggregate) != NULL) { +			p = (struct prefix_ipv6 *)&rp->p;  #ifdef DEBUG -	  vty_out (vty, "R(a) %d/%d %s/%d ", -			 aggregate->count, aggregate->suppress, -			 inet6_ntoa (p->prefix), p->prefixlen); +			vty_out(vty, "R(a) %d/%d %s/%d ", aggregate->count, +				aggregate->suppress, inet6_ntoa(p->prefix), +				p->prefixlen);  #else -	  vty_out (vty, "R(a) %s/%d ", -			 inet6_ntoa (p->prefix), p->prefixlen); +			vty_out(vty, "R(a) %s/%d ", inet6_ntoa(p->prefix), +				p->prefixlen);  #endif /* DEBUG */ -	  vty_out (vty, "\n"); -	  vty_out (vty, "%*s", 18, " "); +			vty_out(vty, "\n"); +			vty_out(vty, "%*s", 18, " "); -	  vty_out (vty, "%*s", 28, " "); -	  vty_out (vty, "self      %2d  %3"ROUTE_TAG_PRI"\n", aggregate->metric, -		   (route_tag_t)aggregate->tag); -	} +			vty_out(vty, "%*s", 28, " "); +			vty_out(vty, "self      %2d  %3" ROUTE_TAG_PRI "\n", +				aggregate->metric, (route_tag_t)aggregate->tag); +		} -      if ((list = rp->info) != NULL) -        for (ALL_LIST_ELEMENTS_RO (list, listnode, rinfo)) -	{ -	  p = (struct prefix_ipv6 *) &rp->p; +		if ((list = rp->info) != NULL) +			for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) { +				p = (struct prefix_ipv6 *)&rp->p;  #ifdef DEBUG -	  vty_out (vty, "%c(%s) 0/%d %s/%d ", -			 zebra_route_char(rinfo->type), -			 ripng_route_subtype_print(rinfo), -			 rinfo->suppress, -			 inet6_ntoa (p->prefix), p->prefixlen); +				vty_out(vty, "%c(%s) 0/%d %s/%d ", +					zebra_route_char(rinfo->type), +					ripng_route_subtype_print(rinfo), +					rinfo->suppress, inet6_ntoa(p->prefix), +					p->prefixlen);  #else -	  vty_out (vty, "%c(%s) %s/%d ", -			 zebra_route_char(rinfo->type), -			 ripng_route_subtype_print(rinfo), -			 inet6_ntoa (p->prefix), p->prefixlen); +				vty_out(vty, "%c(%s) %s/%d ", +					zebra_route_char(rinfo->type), +					ripng_route_subtype_print(rinfo), +					inet6_ntoa(p->prefix), p->prefixlen);  #endif /* DEBUG */ -	  vty_out (vty, "\n"); -	  vty_out (vty, "%*s", 18, " "); -	  len = vty_out (vty, "%s", inet6_ntoa (rinfo->nexthop)); - -	  len = 28 - len; -	  if (len > 0) -	    len = vty_out (vty, "%*s", len, " "); - -	  /* from */ -	  if ((rinfo->type == ZEBRA_ROUTE_RIPNG) &&  -	    (rinfo->sub_type == RIPNG_ROUTE_RTE)) -	  { -	    len = vty_out (vty, "%s", ifindex2ifname(rinfo->ifindex, VRF_DEFAULT)); -	  } else if (rinfo->metric == RIPNG_METRIC_INFINITY) -	  { -	    len = vty_out (vty, "kill"); -	  } else -	    len = vty_out (vty, "self"); - -	  len = 9 - len; -	  if (len > 0) -	    vty_out (vty, "%*s", len, " "); - -	  vty_out (vty, " %2d  %3"ROUTE_TAG_PRI"  ", -		   rinfo->metric, (route_tag_t)rinfo->tag); - -	  /* time */ -	  if ((rinfo->type == ZEBRA_ROUTE_RIPNG) &&  -	    (rinfo->sub_type == RIPNG_ROUTE_RTE)) -	  { -	    /* RTE from remote RIP routers */ -	    ripng_vty_out_uptime (vty, rinfo); -	  } else if (rinfo->metric == RIPNG_METRIC_INFINITY) -	  { -	    /* poisonous reversed routes (gc) */ -	    ripng_vty_out_uptime (vty, rinfo); -	  } - -	  vty_out (vty, "\n"); +				vty_out(vty, "\n"); +				vty_out(vty, "%*s", 18, " "); +				len = vty_out(vty, "%s", +					      inet6_ntoa(rinfo->nexthop)); + +				len = 28 - len; +				if (len > 0) +					len = vty_out(vty, "%*s", len, " "); + +				/* from */ +				if ((rinfo->type == ZEBRA_ROUTE_RIPNG) +				    && (rinfo->sub_type == RIPNG_ROUTE_RTE)) { +					len = vty_out( +						vty, "%s", +						ifindex2ifname(rinfo->ifindex, +							       VRF_DEFAULT)); +				} else if (rinfo->metric +					   == RIPNG_METRIC_INFINITY) { +					len = vty_out(vty, "kill"); +				} else +					len = vty_out(vty, "self"); + +				len = 9 - len; +				if (len > 0) +					vty_out(vty, "%*s", len, " "); + +				vty_out(vty, " %2d  %3" ROUTE_TAG_PRI "  ", +					rinfo->metric, (route_tag_t)rinfo->tag); + +				/* time */ +				if ((rinfo->type == ZEBRA_ROUTE_RIPNG) +				    && (rinfo->sub_type == RIPNG_ROUTE_RTE)) { +					/* RTE from remote RIP routers */ +					ripng_vty_out_uptime(vty, rinfo); +				} else if (rinfo->metric +					   == RIPNG_METRIC_INFINITY) { +					/* poisonous reversed routes (gc) */ +					ripng_vty_out_uptime(vty, rinfo); +				} + +				vty_out(vty, "\n"); +			}  	} -    } -  return CMD_SUCCESS; +	return CMD_SUCCESS;  }  DEFUN (show_ipv6_ripng_status, @@ -2102,61 +2057,60 @@ DEFUN (show_ipv6_ripng_status,         "Show RIPng routes\n"         "IPv6 routing protocol process parameters and statistics\n")  { -  struct listnode *node; -  struct interface *ifp; +	struct listnode *node; +	struct interface *ifp; -  if (! ripng) -    return CMD_SUCCESS; +	if (!ripng) +		return CMD_SUCCESS; -  vty_out (vty, "Routing Protocol is \"RIPng\"\n"); -  vty_out (vty, "  Sending updates every %ld seconds with +/-50%%,", -           ripng->update_time); -  vty_out (vty, " next due in %lu seconds\n", -           thread_timer_remain_second(ripng->t_update)); -  vty_out (vty, "  Timeout after %ld seconds,", ripng->timeout_time); -  vty_out (vty, " garbage collect after %ld seconds\n",ripng->garbage_time); +	vty_out(vty, "Routing Protocol is \"RIPng\"\n"); +	vty_out(vty, "  Sending updates every %ld seconds with +/-50%%,", +		ripng->update_time); +	vty_out(vty, " next due in %lu seconds\n", +		thread_timer_remain_second(ripng->t_update)); +	vty_out(vty, "  Timeout after %ld seconds,", ripng->timeout_time); +	vty_out(vty, " garbage collect after %ld seconds\n", +		ripng->garbage_time); -  /* Filtering status show. */ -  config_show_distribute (vty); +	/* Filtering status show. */ +	config_show_distribute(vty); -  /* Default metric information. */ -  vty_out (vty, "  Default redistribution metric is %d\n", -           ripng->default_metric); +	/* Default metric information. */ +	vty_out(vty, "  Default redistribution metric is %d\n", +		ripng->default_metric); -  /* Redistribute information. */ -  vty_out (vty, "  Redistributing:"); -  ripng_redistribute_write (vty, 0); -  vty_out (vty, "\n"); +	/* Redistribute information. */ +	vty_out(vty, "  Redistributing:"); +	ripng_redistribute_write(vty, 0); +	vty_out(vty, "\n"); -  vty_out (vty, "  Default version control: send version %d,", ripng->version); -  vty_out (vty, " receive version %d \n",ripng->version); +	vty_out(vty, "  Default version control: send version %d,", +		ripng->version); +	vty_out(vty, " receive version %d \n", ripng->version); -  vty_out (vty, "    Interface        Send  Recv\n"); +	vty_out(vty, "    Interface        Send  Recv\n"); -  for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) -    { -      struct ripng_interface *ri; -       -      ri = ifp->info; +	for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) { +		struct ripng_interface *ri; + +		ri = ifp->info; -      if (ri->enable_network || ri->enable_interface) -	{ +		if (ri->enable_network || ri->enable_interface) { -	  vty_out (vty, "    %-17s%-3d   %-3d\n", ifp->name, -		   ripng->version, -		   ripng->version); +			vty_out(vty, "    %-17s%-3d   %-3d\n", ifp->name, +				ripng->version, ripng->version); +		}  	} -    } -  vty_out (vty, "  Routing for Networks:\n"); -  ripng_network_write (vty, 0); +	vty_out(vty, "  Routing for Networks:\n"); +	ripng_network_write(vty, 0); -  vty_out (vty, "  Routing Information Sources:\n"); -  vty_out (vty, -             "    Gateway          BadPackets BadRoutes  Distance Last Update\n"); -  ripng_peer_display (vty); +	vty_out(vty, "  Routing Information Sources:\n"); +	vty_out(vty, +		"    Gateway          BadPackets BadRoutes  Distance Last Update\n"); +	ripng_peer_display(vty); -  return CMD_SUCCESS;   +	return CMD_SUCCESS;  }  DEFUN (clear_ipv6_rip, @@ -2166,45 +2120,41 @@ DEFUN (clear_ipv6_rip,         IPV6_STR         "Clear IPv6 RIP database\n")  { -  struct route_node *rp; -  struct ripng_info *rinfo; -  struct list *list; -  struct listnode *listnode; +	struct route_node *rp; +	struct ripng_info *rinfo; +	struct list *list; +	struct listnode *listnode; -  /* Clear received RIPng routes */ -  for (rp = route_top (ripng->table); rp; rp = route_next (rp)) -    { -      list = rp->info; -      if (list == NULL) -	continue; +	/* Clear received RIPng routes */ +	for (rp = route_top(ripng->table); rp; rp = route_next(rp)) { +		list = rp->info; +		if (list == NULL) +			continue; -      for (ALL_LIST_ELEMENTS_RO (list, listnode, rinfo)) -	{ -	  if (! ripng_route_rte (rinfo)) -	    continue; +		for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) { +			if (!ripng_route_rte(rinfo)) +				continue; -	  if (CHECK_FLAG (rinfo->flags, RIPNG_RTF_FIB)) -	    ripng_zebra_ipv6_delete (rp); -	  break; -	} +			if (CHECK_FLAG(rinfo->flags, RIPNG_RTF_FIB)) +				ripng_zebra_ipv6_delete(rp); +			break; +		} -      if (rinfo) -	{ -	  RIPNG_TIMER_OFF (rinfo->t_timeout); -	  RIPNG_TIMER_OFF (rinfo->t_garbage_collect); -	  listnode_delete (list, rinfo); -	  ripng_info_free (rinfo); -	} +		if (rinfo) { +			RIPNG_TIMER_OFF(rinfo->t_timeout); +			RIPNG_TIMER_OFF(rinfo->t_garbage_collect); +			listnode_delete(list, rinfo); +			ripng_info_free(rinfo); +		} -      if (list_isempty (list)) -	{ -	  list_free (list); -	  rp->info = NULL; -	  route_unlock_node (rp); +		if (list_isempty(list)) { +			list_free(list); +			rp->info = NULL; +			route_unlock_node(rp); +		}  	} -    } -  return CMD_SUCCESS; +	return CMD_SUCCESS;  }  DEFUN_NOSH (router_ripng, @@ -2213,23 +2163,21 @@ DEFUN_NOSH (router_ripng,         "Enable a routing process\n"         "Make RIPng instance command\n")  { -  int ret; +	int ret; -  vty->node = RIPNG_NODE; +	vty->node = RIPNG_NODE; -  if (!ripng) -    { -      ret = ripng_create (); +	if (!ripng) { +		ret = ripng_create(); -      /* Notice to user we couldn't create RIPng. */ -      if (ret < 0) -	{ -	  zlog_warn ("can't create RIPng"); -          return CMD_WARNING_CONFIG_FAILED; +		/* Notice to user we couldn't create RIPng. */ +		if (ret < 0) { +			zlog_warn("can't create RIPng"); +			return CMD_WARNING_CONFIG_FAILED; +		}  	} -    } -  return CMD_SUCCESS; +	return CMD_SUCCESS;  }  DEFUN (no_router_ripng, @@ -2239,9 +2187,9 @@ DEFUN (no_router_ripng,         "Enable a routing process\n"         "Make RIPng instance command\n")  { -  if(ripng) -    ripng_clean(); -  return CMD_SUCCESS; +	if (ripng) +		ripng_clean(); +	return CMD_SUCCESS;  }  DEFUN (ripng_route, @@ -2250,31 +2198,31 @@ DEFUN (ripng_route,         "Static route setup\n"         "Set static RIPng route announcement\n")  { -  int idx_ipv6addr = 1; -  int ret; -  struct prefix_ipv6 p; -  struct route_node *rp; +	int idx_ipv6addr = 1; +	int ret; +	struct prefix_ipv6 p; +	struct route_node *rp; -  ret = str2prefix_ipv6 (argv[idx_ipv6addr]->arg, (struct prefix_ipv6 *)&p); -  if (ret <= 0) -    { -      vty_out (vty, "Malformed address\n"); -      return CMD_WARNING_CONFIG_FAILED; -    } -  apply_mask_ipv6 (&p); +	ret = str2prefix_ipv6(argv[idx_ipv6addr]->arg, +			      (struct prefix_ipv6 *)&p); +	if (ret <= 0) { +		vty_out(vty, "Malformed address\n"); +		return CMD_WARNING_CONFIG_FAILED; +	} +	apply_mask_ipv6(&p); -  rp = route_node_get (ripng->route, (struct prefix *) &p); -  if (rp->info) -    { -      vty_out (vty, "There is already same static route.\n"); -      route_unlock_node (rp); -      return CMD_WARNING_CONFIG_FAILED; -    } -  rp->info = (void *)1; +	rp = route_node_get(ripng->route, (struct prefix *)&p); +	if (rp->info) { +		vty_out(vty, "There is already same static route.\n"); +		route_unlock_node(rp); +		return CMD_WARNING_CONFIG_FAILED; +	} +	rp->info = (void *)1; -  ripng_redistribute_add (ZEBRA_ROUTE_RIPNG, RIPNG_ROUTE_STATIC, &p, 0, NULL, 0); +	ripng_redistribute_add(ZEBRA_ROUTE_RIPNG, RIPNG_ROUTE_STATIC, &p, 0, +			       NULL, 0); -  return CMD_SUCCESS; +	return CMD_SUCCESS;  }  DEFUN (no_ripng_route, @@ -2284,33 +2232,32 @@ DEFUN (no_ripng_route,         "Static route setup\n"         "Delete static RIPng route announcement\n")  { -  int idx_ipv6addr = 2; -  int ret; -  struct prefix_ipv6 p; -  struct route_node *rp; +	int idx_ipv6addr = 2; +	int ret; +	struct prefix_ipv6 p; +	struct route_node *rp; -  ret = str2prefix_ipv6 (argv[idx_ipv6addr]->arg, (struct prefix_ipv6 *)&p); -  if (ret <= 0) -    { -      vty_out (vty, "Malformed address\n"); -      return CMD_WARNING_CONFIG_FAILED; -    } -  apply_mask_ipv6 (&p); +	ret = str2prefix_ipv6(argv[idx_ipv6addr]->arg, +			      (struct prefix_ipv6 *)&p); +	if (ret <= 0) { +		vty_out(vty, "Malformed address\n"); +		return CMD_WARNING_CONFIG_FAILED; +	} +	apply_mask_ipv6(&p); -  rp = route_node_lookup (ripng->route, (struct prefix *) &p); -  if (! rp) -    { -      vty_out (vty, "Can't find static route.\n"); -      return CMD_WARNING_CONFIG_FAILED; -    } +	rp = route_node_lookup(ripng->route, (struct prefix *)&p); +	if (!rp) { +		vty_out(vty, "Can't find static route.\n"); +		return CMD_WARNING_CONFIG_FAILED; +	} -  ripng_redistribute_delete (ZEBRA_ROUTE_RIPNG, RIPNG_ROUTE_STATIC, &p, 0); -  route_unlock_node (rp); +	ripng_redistribute_delete(ZEBRA_ROUTE_RIPNG, RIPNG_ROUTE_STATIC, &p, 0); +	route_unlock_node(rp); -  rp->info = NULL; -  route_unlock_node (rp); +	rp->info = NULL; +	route_unlock_node(rp); -  return CMD_SUCCESS; +	return CMD_SUCCESS;  }  DEFUN (ripng_aggregate_address, @@ -2319,31 +2266,30 @@ DEFUN (ripng_aggregate_address,         "Set aggregate RIPng route announcement\n"         "Aggregate network\n")  { -  int idx_ipv6_prefixlen = 1; -  int ret; -  struct prefix p; -  struct route_node *node; +	int idx_ipv6_prefixlen = 1; +	int ret; +	struct prefix p; +	struct route_node *node; -  ret = str2prefix_ipv6 (argv[idx_ipv6_prefixlen]->arg, (struct prefix_ipv6 *)&p); -  if (ret <= 0) -    { -      vty_out (vty, "Malformed address\n"); -      return CMD_WARNING_CONFIG_FAILED; -    } +	ret = str2prefix_ipv6(argv[idx_ipv6_prefixlen]->arg, +			      (struct prefix_ipv6 *)&p); +	if (ret <= 0) { +		vty_out(vty, "Malformed address\n"); +		return CMD_WARNING_CONFIG_FAILED; +	} -  /* Check aggregate alredy exist or not. */ -  node = route_node_get (ripng->aggregate, &p); -  if (node->info) -    { -      vty_out (vty, "There is already same aggregate route.\n"); -      route_unlock_node (node); -      return CMD_WARNING_CONFIG_FAILED; -    } -  node->info = (void *)1; +	/* Check aggregate alredy exist or not. */ +	node = route_node_get(ripng->aggregate, &p); +	if (node->info) { +		vty_out(vty, "There is already same aggregate route.\n"); +		route_unlock_node(node); +		return CMD_WARNING_CONFIG_FAILED; +	} +	node->info = (void *)1; -  ripng_aggregate_add (&p); +	ripng_aggregate_add(&p); -  return CMD_SUCCESS; +	return CMD_SUCCESS;  }  DEFUN (no_ripng_aggregate_address, @@ -2353,31 +2299,30 @@ DEFUN (no_ripng_aggregate_address,         "Delete aggregate RIPng route announcement\n"         "Aggregate network\n")  { -  int idx_ipv6_prefixlen = 2; -  int ret; -  struct prefix p; -  struct route_node *rn; +	int idx_ipv6_prefixlen = 2; +	int ret; +	struct prefix p; +	struct route_node *rn; -  ret = str2prefix_ipv6 (argv[idx_ipv6_prefixlen]->arg, (struct prefix_ipv6 *) &p); -  if (ret <= 0) -    { -      vty_out (vty, "Malformed address\n"); -      return CMD_WARNING_CONFIG_FAILED; -    } +	ret = str2prefix_ipv6(argv[idx_ipv6_prefixlen]->arg, +			      (struct prefix_ipv6 *)&p); +	if (ret <= 0) { +		vty_out(vty, "Malformed address\n"); +		return CMD_WARNING_CONFIG_FAILED; +	} -  rn = route_node_lookup (ripng->aggregate, &p); -  if (! rn) -    { -      vty_out (vty, "Can't find aggregate route.\n"); -      return CMD_WARNING_CONFIG_FAILED; -    } -  route_unlock_node (rn); -  rn->info = NULL; -  route_unlock_node (rn); +	rn = route_node_lookup(ripng->aggregate, &p); +	if (!rn) { +		vty_out(vty, "Can't find aggregate route.\n"); +		return CMD_WARNING_CONFIG_FAILED; +	} +	route_unlock_node(rn); +	rn->info = NULL; +	route_unlock_node(rn); -  ripng_aggregate_delete (&p); +	ripng_aggregate_delete(&p); -  return CMD_SUCCESS; +	return CMD_SUCCESS;  }  DEFUN (ripng_default_metric, @@ -2386,12 +2331,11 @@ DEFUN (ripng_default_metric,         "Set a metric of redistribute routes\n"         "Default metric\n")  { -  int idx_number = 1; -  if (ripng) -    { -      ripng->default_metric = atoi (argv[idx_number]->arg); -    } -  return CMD_SUCCESS; +	int idx_number = 1; +	if (ripng) { +		ripng->default_metric = atoi(argv[idx_number]->arg); +	} +	return CMD_SUCCESS;  }  DEFUN (no_ripng_default_metric, @@ -2401,11 +2345,10 @@ DEFUN (no_ripng_default_metric,         "Set a metric of redistribute routes\n"         "Default metric\n")  { -  if (ripng) -    { -      ripng->default_metric = RIPNG_DEFAULT_METRIC_DEFAULT; -    } -  return CMD_SUCCESS; +	if (ripng) { +		ripng->default_metric = RIPNG_DEFAULT_METRIC_DEFAULT; +	} +	return CMD_SUCCESS;  } @@ -2521,26 +2464,26 @@ DEFUN (ripng_timers,         "Routing information timeout timer. Default is 180.\n"         "Garbage collection timer. Default is 120.\n")  { -  int idx_number = 2; -  int idx_number_2 = 3; -  int idx_number_3 = 4; -  unsigned long update; -  unsigned long timeout; -  unsigned long garbage; +	int idx_number = 2; +	int idx_number_2 = 3; +	int idx_number_3 = 4; +	unsigned long update; +	unsigned long timeout; +	unsigned long garbage; -  update = strtoul(argv[idx_number]->arg, NULL, 10); -  timeout = strtoul(argv[idx_number_2]->arg, NULL, 10); -  garbage = strtoul(argv[idx_number_3]->arg, NULL, 10); +	update = strtoul(argv[idx_number]->arg, NULL, 10); +	timeout = strtoul(argv[idx_number_2]->arg, NULL, 10); +	garbage = strtoul(argv[idx_number_3]->arg, NULL, 10); -  /* Set each timer value. */ -  ripng->update_time = update; -  ripng->timeout_time = timeout; -  ripng->garbage_time = garbage; +	/* Set each timer value. */ +	ripng->update_time = update; +	ripng->timeout_time = timeout; +	ripng->garbage_time = garbage; -  /* Reset update timer thread. */ -  ripng_event (RIPNG_UPDATE_EVENT, 0); +	/* Reset update timer thread. */ +	ripng_event(RIPNG_UPDATE_EVENT, 0); -  return CMD_SUCCESS; +	return CMD_SUCCESS;  }  DEFUN (no_ripng_timers, @@ -2553,15 +2496,15 @@ DEFUN (no_ripng_timers,         "Routing information timeout timer. Default is 180.\n"         "Garbage collection timer. Default is 120.\n")  { -  /* Set each timer value to the default. */ -  ripng->update_time = RIPNG_UPDATE_TIMER_DEFAULT; -  ripng->timeout_time = RIPNG_TIMEOUT_TIMER_DEFAULT; -  ripng->garbage_time = RIPNG_GARBAGE_TIMER_DEFAULT; +	/* Set each timer value to the default. */ +	ripng->update_time = RIPNG_UPDATE_TIMER_DEFAULT; +	ripng->timeout_time = RIPNG_TIMEOUT_TIMER_DEFAULT; +	ripng->garbage_time = RIPNG_GARBAGE_TIMER_DEFAULT; -  /* Reset update timer thread. */ -  ripng_event (RIPNG_UPDATE_EVENT, 0); +	/* Reset update timer thread. */ +	ripng_event(RIPNG_UPDATE_EVENT, 0); -  return CMD_SUCCESS; +	return CMD_SUCCESS;  }  #if 0 @@ -2598,16 +2541,17 @@ DEFUN (ripng_default_information_originate,         "Default route information\n"         "Distribute default route\n")  { -  struct prefix_ipv6 p; +	struct prefix_ipv6 p; -  if (! ripng ->default_information) { -    ripng->default_information = 1; +	if (!ripng->default_information) { +		ripng->default_information = 1; -    str2prefix_ipv6 ("::/0", &p); -    ripng_redistribute_add (ZEBRA_ROUTE_RIPNG, RIPNG_ROUTE_DEFAULT, &p, 0, NULL, 0); -  } +		str2prefix_ipv6("::/0", &p); +		ripng_redistribute_add(ZEBRA_ROUTE_RIPNG, RIPNG_ROUTE_DEFAULT, +				       &p, 0, NULL, 0); +	} -  return CMD_SUCCESS; +	return CMD_SUCCESS;  }  DEFUN (no_ripng_default_information_originate, @@ -2617,56 +2561,55 @@ DEFUN (no_ripng_default_information_originate,         "Default route information\n"         "Distribute default route\n")  { -  struct prefix_ipv6 p; +	struct prefix_ipv6 p; -  if (ripng->default_information) { -    ripng->default_information = 0; +	if (ripng->default_information) { +		ripng->default_information = 0; -    str2prefix_ipv6 ("::/0", &p); -    ripng_redistribute_delete (ZEBRA_ROUTE_RIPNG, RIPNG_ROUTE_DEFAULT, &p, 0); -  } +		str2prefix_ipv6("::/0", &p); +		ripng_redistribute_delete(ZEBRA_ROUTE_RIPNG, +					  RIPNG_ROUTE_DEFAULT, &p, 0); +	} -  return CMD_SUCCESS; +	return CMD_SUCCESS;  }  /* Update ECMP routes to zebra when ECMP is disabled. */ -static void -ripng_ecmp_disable (void) -{ -  struct route_node *rp; -  struct ripng_info *rinfo, *tmp_rinfo; -  struct list *list; -  struct listnode *node, *nextnode; - -  if (!ripng) -    return; - -  for (rp = route_top (ripng->table); rp; rp = route_next (rp)) -    if ((list = rp->info) != NULL && listcount (list) > 1) -      { -        rinfo = listgetdata (listhead (list)); -        if (!ripng_route_rte (rinfo)) -          continue; - -        /* Drop all other entries, except the first one. */ -        for (ALL_LIST_ELEMENTS (list, node, nextnode, tmp_rinfo)) -          if (tmp_rinfo != rinfo) -            { -              RIPNG_TIMER_OFF (tmp_rinfo->t_timeout); -              RIPNG_TIMER_OFF (tmp_rinfo->t_garbage_collect); -              list_delete_node (list, node); -              ripng_info_free (tmp_rinfo); -            } - -        /* Update zebra. */ -        ripng_zebra_ipv6_add (rp); - -        /* Set the route change flag. */ -        SET_FLAG (rinfo->flags, RIPNG_RTF_CHANGED); - -        /* Signal the output process to trigger an update. */ -        ripng_event (RIPNG_TRIGGERED_UPDATE, 0); -      } +static void ripng_ecmp_disable(void) +{ +	struct route_node *rp; +	struct ripng_info *rinfo, *tmp_rinfo; +	struct list *list; +	struct listnode *node, *nextnode; + +	if (!ripng) +		return; + +	for (rp = route_top(ripng->table); rp; rp = route_next(rp)) +		if ((list = rp->info) != NULL && listcount(list) > 1) { +			rinfo = listgetdata(listhead(list)); +			if (!ripng_route_rte(rinfo)) +				continue; + +			/* Drop all other entries, except the first one. */ +			for (ALL_LIST_ELEMENTS(list, node, nextnode, tmp_rinfo)) +				if (tmp_rinfo != rinfo) { +					RIPNG_TIMER_OFF(tmp_rinfo->t_timeout); +					RIPNG_TIMER_OFF( +						tmp_rinfo->t_garbage_collect); +					list_delete_node(list, node); +					ripng_info_free(tmp_rinfo); +				} + +			/* Update zebra. */ +			ripng_zebra_ipv6_add(rp); + +			/* Set the route change flag. */ +			SET_FLAG(rinfo->flags, RIPNG_RTF_CHANGED); + +			/* Signal the output process to trigger an update. */ +			ripng_event(RIPNG_TRIGGERED_UPDATE, 0); +		}  }  DEFUN (ripng_allow_ecmp, @@ -2674,15 +2617,14 @@ DEFUN (ripng_allow_ecmp,         "allow-ecmp",         "Allow Equal Cost MultiPath\n")  { -  if (ripng->ecmp) -    { -      vty_out (vty, "ECMP is already enabled.\n"); -      return CMD_WARNING_CONFIG_FAILED; -    } +	if (ripng->ecmp) { +		vty_out(vty, "ECMP is already enabled.\n"); +		return CMD_WARNING_CONFIG_FAILED; +	} -  ripng->ecmp = 1; -  zlog_info ("ECMP is enabled."); -  return CMD_SUCCESS; +	ripng->ecmp = 1; +	zlog_info("ECMP is enabled."); +	return CMD_SUCCESS;  }  DEFUN (no_ripng_allow_ecmp, @@ -2691,75 +2633,71 @@ DEFUN (no_ripng_allow_ecmp,         NO_STR         "Allow Equal Cost MultiPath\n")  { -  if (!ripng->ecmp) -    { -      vty_out (vty, "ECMP is already disabled.\n"); -      return CMD_WARNING_CONFIG_FAILED; -    } +	if (!ripng->ecmp) { +		vty_out(vty, "ECMP is already disabled.\n"); +		return CMD_WARNING_CONFIG_FAILED; +	} -  ripng->ecmp = 0; -  zlog_info ("ECMP is disabled."); -  ripng_ecmp_disable (); -  return CMD_SUCCESS; +	ripng->ecmp = 0; +	zlog_info("ECMP is disabled."); +	ripng_ecmp_disable(); +	return CMD_SUCCESS;  }  /* RIPng configuration write function. */ -static int -ripng_config_write (struct vty *vty) -{ -  int ripng_network_write (struct vty *, int); -  void ripng_redistribute_write (struct vty *, int); -  int write = 0; -  struct route_node *rp; - -  if (ripng) -    { - -      /* RIPng router. */ -      vty_out (vty, "router ripng\n"); - -      if (ripng->default_information) -	vty_out (vty, " default-information originate\n"); - -      ripng_network_write (vty, 1); - -      /* RIPng default metric configuration */ -      if (ripng->default_metric != RIPNG_DEFAULT_METRIC_DEFAULT) -        vty_out (vty, " default-metric %d\n", -		 ripng->default_metric); - -      ripng_redistribute_write (vty, 1); - -      /* RIP offset-list configuration. */ -      config_write_ripng_offset_list (vty); -       -      /* RIPng aggregate routes. */ -      for (rp = route_top (ripng->aggregate); rp; rp = route_next (rp)) -	if (rp->info != NULL) -	  vty_out (vty, " aggregate-address %s/%d\n",  -		   inet6_ntoa (rp->p.u.prefix6), -		   rp->p.prefixlen); - -      /* ECMP configuration. */ -      if (ripng->ecmp) -        vty_out (vty, " allow-ecmp\n"); - -      /* RIPng static routes. */ -      for (rp = route_top (ripng->route); rp; rp = route_next (rp)) -	if (rp->info != NULL) -	  vty_out (vty, " route %s/%d\n", inet6_ntoa (rp->p.u.prefix6), -		   rp->p.prefixlen); - -      /* RIPng timers configuration. */ -      if (ripng->update_time != RIPNG_UPDATE_TIMER_DEFAULT || -	  ripng->timeout_time != RIPNG_TIMEOUT_TIMER_DEFAULT || -	  ripng->garbage_time != RIPNG_GARBAGE_TIMER_DEFAULT) -	{ -	  vty_out (vty, " timers basic %ld %ld %ld\n", -		   ripng->update_time, -		   ripng->timeout_time, -		   ripng->garbage_time); -	} +static int ripng_config_write(struct vty *vty) +{ +	int ripng_network_write(struct vty *, int); +	void ripng_redistribute_write(struct vty *, int); +	int write = 0; +	struct route_node *rp; + +	if (ripng) { + +		/* RIPng router. */ +		vty_out(vty, "router ripng\n"); + +		if (ripng->default_information) +			vty_out(vty, " default-information originate\n"); + +		ripng_network_write(vty, 1); + +		/* RIPng default metric configuration */ +		if (ripng->default_metric != RIPNG_DEFAULT_METRIC_DEFAULT) +			vty_out(vty, " default-metric %d\n", +				ripng->default_metric); + +		ripng_redistribute_write(vty, 1); + +		/* RIP offset-list configuration. */ +		config_write_ripng_offset_list(vty); + +		/* RIPng aggregate routes. */ +		for (rp = route_top(ripng->aggregate); rp; rp = route_next(rp)) +			if (rp->info != NULL) +				vty_out(vty, " aggregate-address %s/%d\n", +					inet6_ntoa(rp->p.u.prefix6), +					rp->p.prefixlen); + +		/* ECMP configuration. */ +		if (ripng->ecmp) +			vty_out(vty, " allow-ecmp\n"); + +		/* RIPng static routes. */ +		for (rp = route_top(ripng->route); rp; rp = route_next(rp)) +			if (rp->info != NULL) +				vty_out(vty, " route %s/%d\n", +					inet6_ntoa(rp->p.u.prefix6), +					rp->p.prefixlen); + +		/* RIPng timers configuration. */ +		if (ripng->update_time != RIPNG_UPDATE_TIMER_DEFAULT +		    || ripng->timeout_time != RIPNG_TIMEOUT_TIMER_DEFAULT +		    || ripng->garbage_time != RIPNG_GARBAGE_TIMER_DEFAULT) { +			vty_out(vty, " timers basic %ld %ld %ld\n", +				ripng->update_time, ripng->timeout_time, +				ripng->garbage_time); +		}  #if 0        if (ripng->update_time != RIPNG_UPDATE_TIMER_DEFAULT)  	vty_out (vty, " update-timer %d\n", ripng->update_time); @@ -2769,326 +2707,301 @@ ripng_config_write (struct vty *vty)  	vty_out (vty, " garbage-timer %d\n", ripng->garbage_time);  #endif /* 0 */ -      write += config_write_distribute (vty); +		write += config_write_distribute(vty); -      write += config_write_if_rmap (vty); +		write += config_write_if_rmap(vty); -      write++; -    } -  return write; +		write++; +	} +	return write;  }  /* RIPng node structure. */ -static struct cmd_node cmd_ripng_node = -{ -  RIPNG_NODE, -  "%s(config-router)# ", -  1, +static struct cmd_node cmd_ripng_node = { +	RIPNG_NODE, "%s(config-router)# ", 1,  }; -static void -ripng_distribute_update (struct distribute *dist) -{ -  struct interface *ifp; -  struct ripng_interface *ri; -  struct access_list *alist; -  struct prefix_list *plist; - -  if (! dist->ifname) -    return; - -  ifp = if_lookup_by_name (dist->ifname, VRF_DEFAULT); -  if (ifp == NULL) -    return; - -  ri = ifp->info; - -  if (dist->list[DISTRIBUTE_V6_IN]) -    { -      alist = access_list_lookup (AFI_IP6, dist->list[DISTRIBUTE_V6_IN]); -      if (alist) -	ri->list[RIPNG_FILTER_IN] = alist; -      else -	ri->list[RIPNG_FILTER_IN] = NULL; -    } -  else -    ri->list[RIPNG_FILTER_IN] = NULL; - -  if (dist->list[DISTRIBUTE_V6_OUT]) -    { -      alist = access_list_lookup (AFI_IP6, dist->list[DISTRIBUTE_V6_OUT]); -      if (alist) -	ri->list[RIPNG_FILTER_OUT] = alist; -      else -	ri->list[RIPNG_FILTER_OUT] = NULL; -    } -  else -    ri->list[RIPNG_FILTER_OUT] = NULL; - -  if (dist->prefix[DISTRIBUTE_V6_IN]) -    { -      plist = prefix_list_lookup (AFI_IP6, dist->prefix[DISTRIBUTE_V6_IN]); -      if (plist) -	ri->prefix[RIPNG_FILTER_IN] = plist; -      else -	ri->prefix[RIPNG_FILTER_IN] = NULL; -    } -  else -    ri->prefix[RIPNG_FILTER_IN] = NULL; - -  if (dist->prefix[DISTRIBUTE_V6_OUT]) -    { -      plist = prefix_list_lookup (AFI_IP6, dist->prefix[DISTRIBUTE_V6_OUT]); -      if (plist) -	ri->prefix[RIPNG_FILTER_OUT] = plist; -      else -	ri->prefix[RIPNG_FILTER_OUT] = NULL; -    } -  else -    ri->prefix[RIPNG_FILTER_OUT] = NULL; -} - -void -ripng_distribute_update_interface (struct interface *ifp) -{ -  struct distribute *dist; - -  dist = distribute_lookup (ifp->name); -  if (dist) -    ripng_distribute_update (dist); +static void ripng_distribute_update(struct distribute *dist) +{ +	struct interface *ifp; +	struct ripng_interface *ri; +	struct access_list *alist; +	struct prefix_list *plist; + +	if (!dist->ifname) +		return; + +	ifp = if_lookup_by_name(dist->ifname, VRF_DEFAULT); +	if (ifp == NULL) +		return; + +	ri = ifp->info; + +	if (dist->list[DISTRIBUTE_V6_IN]) { +		alist = access_list_lookup(AFI_IP6, +					   dist->list[DISTRIBUTE_V6_IN]); +		if (alist) +			ri->list[RIPNG_FILTER_IN] = alist; +		else +			ri->list[RIPNG_FILTER_IN] = NULL; +	} else +		ri->list[RIPNG_FILTER_IN] = NULL; + +	if (dist->list[DISTRIBUTE_V6_OUT]) { +		alist = access_list_lookup(AFI_IP6, +					   dist->list[DISTRIBUTE_V6_OUT]); +		if (alist) +			ri->list[RIPNG_FILTER_OUT] = alist; +		else +			ri->list[RIPNG_FILTER_OUT] = NULL; +	} else +		ri->list[RIPNG_FILTER_OUT] = NULL; + +	if (dist->prefix[DISTRIBUTE_V6_IN]) { +		plist = prefix_list_lookup(AFI_IP6, +					   dist->prefix[DISTRIBUTE_V6_IN]); +		if (plist) +			ri->prefix[RIPNG_FILTER_IN] = plist; +		else +			ri->prefix[RIPNG_FILTER_IN] = NULL; +	} else +		ri->prefix[RIPNG_FILTER_IN] = NULL; + +	if (dist->prefix[DISTRIBUTE_V6_OUT]) { +		plist = prefix_list_lookup(AFI_IP6, +					   dist->prefix[DISTRIBUTE_V6_OUT]); +		if (plist) +			ri->prefix[RIPNG_FILTER_OUT] = plist; +		else +			ri->prefix[RIPNG_FILTER_OUT] = NULL; +	} else +		ri->prefix[RIPNG_FILTER_OUT] = NULL; +} + +void ripng_distribute_update_interface(struct interface *ifp) +{ +	struct distribute *dist; + +	dist = distribute_lookup(ifp->name); +	if (dist) +		ripng_distribute_update(dist);  }  /* Update all interface's distribute list. */ -static void -ripng_distribute_update_all (struct prefix_list *notused) +static void ripng_distribute_update_all(struct prefix_list *notused)  { -  struct interface *ifp; -  struct listnode *node; +	struct interface *ifp; +	struct listnode *node; -  for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) -    ripng_distribute_update_interface (ifp); +	for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) +		ripng_distribute_update_interface(ifp);  } -static void -ripng_distribute_update_all_wrapper (struct access_list *notused) +static void ripng_distribute_update_all_wrapper(struct access_list *notused)  { -  ripng_distribute_update_all(NULL); +	ripng_distribute_update_all(NULL);  }  /* delete all the added ripng routes. */ -void -ripng_clean() -{ -  int i; -  struct route_node *rp; -  struct ripng_info *rinfo; -  struct ripng_aggregate *aggregate; -  struct list *list = NULL; -  struct listnode *listnode = NULL; - -  if (ripng) { -    /* Clear RIPng routes */ -    for (rp = route_top (ripng->table); rp; rp = route_next (rp)) -      { -        if ((list = rp->info) != NULL) -          { -            rinfo = listgetdata (listhead (list)); -            if (ripng_route_rte (rinfo)) -              ripng_zebra_ipv6_delete (rp); - -            for (ALL_LIST_ELEMENTS_RO (list, listnode, rinfo)) -              { -                RIPNG_TIMER_OFF (rinfo->t_timeout); -                RIPNG_TIMER_OFF (rinfo->t_garbage_collect); -                ripng_info_free (rinfo); -              } -            list_delete (list); -            rp->info = NULL; -            route_unlock_node (rp); -          } - -        if ((aggregate = rp->aggregate) != NULL) -          { -            ripng_aggregate_free (aggregate); -            rp->aggregate = NULL; -            route_unlock_node (rp); -          } -    } +void ripng_clean() +{ +	int i; +	struct route_node *rp; +	struct ripng_info *rinfo; +	struct ripng_aggregate *aggregate; +	struct list *list = NULL; +	struct listnode *listnode = NULL; + +	if (ripng) { +		/* Clear RIPng routes */ +		for (rp = route_top(ripng->table); rp; rp = route_next(rp)) { +			if ((list = rp->info) != NULL) { +				rinfo = listgetdata(listhead(list)); +				if (ripng_route_rte(rinfo)) +					ripng_zebra_ipv6_delete(rp); + +				for (ALL_LIST_ELEMENTS_RO(list, listnode, +							  rinfo)) { +					RIPNG_TIMER_OFF(rinfo->t_timeout); +					RIPNG_TIMER_OFF( +						rinfo->t_garbage_collect); +					ripng_info_free(rinfo); +				} +				list_delete(list); +				rp->info = NULL; +				route_unlock_node(rp); +			} + +			if ((aggregate = rp->aggregate) != NULL) { +				ripng_aggregate_free(aggregate); +				rp->aggregate = NULL; +				route_unlock_node(rp); +			} +		} -    /* Cancel the RIPng timers */ -    RIPNG_TIMER_OFF (ripng->t_update); -    RIPNG_TIMER_OFF (ripng->t_triggered_update); -    RIPNG_TIMER_OFF (ripng->t_triggered_interval); +		/* Cancel the RIPng timers */ +		RIPNG_TIMER_OFF(ripng->t_update); +		RIPNG_TIMER_OFF(ripng->t_triggered_update); +		RIPNG_TIMER_OFF(ripng->t_triggered_interval); -    /* Cancel the read thread */ -    if (ripng->t_read) { -      thread_cancel (ripng->t_read); -      ripng->t_read = NULL; -    } +		/* Cancel the read thread */ +		if (ripng->t_read) { +			thread_cancel(ripng->t_read); +			ripng->t_read = NULL; +		} -    /* Close the RIPng socket */ -    if (ripng->sock >= 0) { -      close(ripng->sock); -      ripng->sock = -1; -    } +		/* Close the RIPng socket */ +		if (ripng->sock >= 0) { +			close(ripng->sock); +			ripng->sock = -1; +		} -    /* Static RIPng route configuration. */ -    for (rp = route_top (ripng->route); rp; rp = route_next (rp)) -      if (rp->info) { -        rp->info = NULL; -        route_unlock_node (rp); -    } +		/* Static RIPng route configuration. */ +		for (rp = route_top(ripng->route); rp; rp = route_next(rp)) +			if (rp->info) { +				rp->info = NULL; +				route_unlock_node(rp); +			} -    /* RIPng aggregated prefixes */ -    for (rp = route_top (ripng->aggregate); rp; rp = route_next (rp)) -      if (rp->info) { -          rp->info = NULL; -          route_unlock_node (rp); -    } +		/* RIPng aggregated prefixes */ +		for (rp = route_top(ripng->aggregate); rp; rp = route_next(rp)) +			if (rp->info) { +				rp->info = NULL; +				route_unlock_node(rp); +			} -    for (i = 0; i < ZEBRA_ROUTE_MAX; i++) -      if (ripng->route_map[i].name) -        free (ripng->route_map[i].name); +		for (i = 0; i < ZEBRA_ROUTE_MAX; i++) +			if (ripng->route_map[i].name) +				free(ripng->route_map[i].name); -    XFREE (MTYPE_ROUTE_TABLE, ripng->table); -    XFREE (MTYPE_ROUTE_TABLE, ripng->route); -    XFREE (MTYPE_ROUTE_TABLE, ripng->aggregate); +		XFREE(MTYPE_ROUTE_TABLE, ripng->table); +		XFREE(MTYPE_ROUTE_TABLE, ripng->route); +		XFREE(MTYPE_ROUTE_TABLE, ripng->aggregate); -    stream_free (ripng->ibuf); -    stream_free (ripng->obuf); +		stream_free(ripng->ibuf); +		stream_free(ripng->obuf); -    XFREE (MTYPE_RIPNG, ripng); -    ripng = NULL; -  } /* if (ripng) */ +		XFREE(MTYPE_RIPNG, ripng); +		ripng = NULL; +	} /* if (ripng) */ -  ripng_clean_network(); -  ripng_passive_interface_clean (); -  ripng_offset_clean (); -  ripng_interface_clean (); -  ripng_redistribute_clean (); +	ripng_clean_network(); +	ripng_passive_interface_clean(); +	ripng_offset_clean(); +	ripng_interface_clean(); +	ripng_redistribute_clean();  }  /* Reset all values to the default settings. */ -void -ripng_reset () +void ripng_reset()  { -  /* Call ripd related reset functions. */ -  ripng_debug_reset (); -  ripng_route_map_reset (); +	/* Call ripd related reset functions. */ +	ripng_debug_reset(); +	ripng_route_map_reset(); -  /* Call library reset functions. */ -  vty_reset (); -  access_list_reset (); -  prefix_list_reset (); +	/* Call library reset functions. */ +	vty_reset(); +	access_list_reset(); +	prefix_list_reset(); -  distribute_list_reset (); +	distribute_list_reset(); -  ripng_interface_reset (); +	ripng_interface_reset(); -  ripng_zclient_reset (); +	ripng_zclient_reset();  } -static void -ripng_if_rmap_update (struct if_rmap *if_rmap) +static void ripng_if_rmap_update(struct if_rmap *if_rmap)  { -  struct interface *ifp; -  struct ripng_interface *ri; -  struct route_map *rmap; +	struct interface *ifp; +	struct ripng_interface *ri; +	struct route_map *rmap; -  ifp = if_lookup_by_name (if_rmap->ifname, VRF_DEFAULT); -  if (ifp == NULL) -    return; +	ifp = if_lookup_by_name(if_rmap->ifname, VRF_DEFAULT); +	if (ifp == NULL) +		return; -  ri = ifp->info; +	ri = ifp->info; -  if (if_rmap->routemap[IF_RMAP_IN]) -    { -      rmap = route_map_lookup_by_name (if_rmap->routemap[IF_RMAP_IN]); -      if (rmap) -	ri->routemap[IF_RMAP_IN] = rmap; -      else -	ri->routemap[IF_RMAP_IN] = NULL; -    } -  else -    ri->routemap[RIPNG_FILTER_IN] = NULL; +	if (if_rmap->routemap[IF_RMAP_IN]) { +		rmap = route_map_lookup_by_name(if_rmap->routemap[IF_RMAP_IN]); +		if (rmap) +			ri->routemap[IF_RMAP_IN] = rmap; +		else +			ri->routemap[IF_RMAP_IN] = NULL; +	} else +		ri->routemap[RIPNG_FILTER_IN] = NULL; -  if (if_rmap->routemap[IF_RMAP_OUT]) -    { -      rmap = route_map_lookup_by_name (if_rmap->routemap[IF_RMAP_OUT]); -      if (rmap) -	ri->routemap[IF_RMAP_OUT] = rmap; -      else -	ri->routemap[IF_RMAP_OUT] = NULL; -    } -  else -    ri->routemap[RIPNG_FILTER_OUT] = NULL; +	if (if_rmap->routemap[IF_RMAP_OUT]) { +		rmap = route_map_lookup_by_name(if_rmap->routemap[IF_RMAP_OUT]); +		if (rmap) +			ri->routemap[IF_RMAP_OUT] = rmap; +		else +			ri->routemap[IF_RMAP_OUT] = NULL; +	} else +		ri->routemap[RIPNG_FILTER_OUT] = NULL;  } -void -ripng_if_rmap_update_interface (struct interface *ifp) +void ripng_if_rmap_update_interface(struct interface *ifp)  { -  struct if_rmap *if_rmap; +	struct if_rmap *if_rmap; -  if_rmap = if_rmap_lookup (ifp->name); -  if (if_rmap) -    ripng_if_rmap_update (if_rmap); +	if_rmap = if_rmap_lookup(ifp->name); +	if (if_rmap) +		ripng_if_rmap_update(if_rmap);  } -static void -ripng_routemap_update_redistribute (void) +static void ripng_routemap_update_redistribute(void)  { -  int i; +	int i; -  if (ripng) -    { -      for (i = 0; i < ZEBRA_ROUTE_MAX; i++)  -	{ -	  if (ripng->route_map[i].name) -	    ripng->route_map[i].map =  -	      route_map_lookup_by_name (ripng->route_map[i].name); +	if (ripng) { +		for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { +			if (ripng->route_map[i].name) +				ripng->route_map[i].map = +					route_map_lookup_by_name( +						ripng->route_map[i].name); +		}  	} -    }  } -static void -ripng_routemap_update (const char *unused) +static void ripng_routemap_update(const char *unused)  { -  struct interface *ifp; -  struct listnode *node; +	struct interface *ifp; +	struct listnode *node; -  for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) -    ripng_if_rmap_update_interface (ifp); +	for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) +		ripng_if_rmap_update_interface(ifp); -  ripng_routemap_update_redistribute (); +	ripng_routemap_update_redistribute();  }  /* Initialize ripng structure and set commands. */ -void -ripng_init () +void ripng_init()  { -  /* Install RIPNG_NODE. */ -  install_node (&cmd_ripng_node, ripng_config_write); +	/* Install RIPNG_NODE. */ +	install_node(&cmd_ripng_node, ripng_config_write); -  /* Install ripng commands. */ -  install_element (VIEW_NODE, &show_ipv6_ripng_cmd); -  install_element (VIEW_NODE, &show_ipv6_ripng_status_cmd); +	/* Install ripng commands. */ +	install_element(VIEW_NODE, &show_ipv6_ripng_cmd); +	install_element(VIEW_NODE, &show_ipv6_ripng_status_cmd); -  install_element (ENABLE_NODE, &clear_ipv6_rip_cmd); +	install_element(ENABLE_NODE, &clear_ipv6_rip_cmd); -  install_element (CONFIG_NODE, &router_ripng_cmd); -  install_element (CONFIG_NODE, &no_router_ripng_cmd); +	install_element(CONFIG_NODE, &router_ripng_cmd); +	install_element(CONFIG_NODE, &no_router_ripng_cmd); -  install_default (RIPNG_NODE); -  install_element (RIPNG_NODE, &ripng_route_cmd); -  install_element (RIPNG_NODE, &no_ripng_route_cmd); -  install_element (RIPNG_NODE, &ripng_aggregate_address_cmd); -  install_element (RIPNG_NODE, &no_ripng_aggregate_address_cmd); +	install_default(RIPNG_NODE); +	install_element(RIPNG_NODE, &ripng_route_cmd); +	install_element(RIPNG_NODE, &no_ripng_route_cmd); +	install_element(RIPNG_NODE, &ripng_aggregate_address_cmd); +	install_element(RIPNG_NODE, &no_ripng_aggregate_address_cmd); -  install_element (RIPNG_NODE, &ripng_default_metric_cmd); -  install_element (RIPNG_NODE, &no_ripng_default_metric_cmd); +	install_element(RIPNG_NODE, &ripng_default_metric_cmd); +	install_element(RIPNG_NODE, &no_ripng_default_metric_cmd); -  install_element (RIPNG_NODE, &ripng_timers_cmd); -  install_element (RIPNG_NODE, &no_ripng_timers_cmd); +	install_element(RIPNG_NODE, &ripng_timers_cmd); +	install_element(RIPNG_NODE, &no_ripng_timers_cmd);  #if 0    install_element (VIEW_NODE, &show_ipv6_protocols_cmd);    install_element (RIPNG_NODE, &ripng_update_timer_cmd); @@ -3099,38 +3012,39 @@ ripng_init ()    install_element (RIPNG_NODE, &no_ripng_garbage_timer_cmd);  #endif /* 0 */ -  install_element (RIPNG_NODE, &ripng_default_information_originate_cmd); -  install_element (RIPNG_NODE, &no_ripng_default_information_originate_cmd); +	install_element(RIPNG_NODE, &ripng_default_information_originate_cmd); +	install_element(RIPNG_NODE, +			&no_ripng_default_information_originate_cmd); -  install_element (RIPNG_NODE, &ripng_allow_ecmp_cmd); -  install_element (RIPNG_NODE, &no_ripng_allow_ecmp_cmd); +	install_element(RIPNG_NODE, &ripng_allow_ecmp_cmd); +	install_element(RIPNG_NODE, &no_ripng_allow_ecmp_cmd); -  ripng_if_init (); -  ripng_debug_init (); +	ripng_if_init(); +	ripng_debug_init(); -  /* Access list install. */ -  access_list_init (); -  access_list_add_hook (ripng_distribute_update_all_wrapper); -  access_list_delete_hook (ripng_distribute_update_all_wrapper); +	/* Access list install. */ +	access_list_init(); +	access_list_add_hook(ripng_distribute_update_all_wrapper); +	access_list_delete_hook(ripng_distribute_update_all_wrapper); -  /* Prefix list initialize.*/ -  prefix_list_init (); -  prefix_list_add_hook (ripng_distribute_update_all); -  prefix_list_delete_hook (ripng_distribute_update_all); +	/* Prefix list initialize.*/ +	prefix_list_init(); +	prefix_list_add_hook(ripng_distribute_update_all); +	prefix_list_delete_hook(ripng_distribute_update_all); -  /* Distribute list install. */ -  distribute_list_init (RIPNG_NODE); -  distribute_list_add_hook (ripng_distribute_update); -  distribute_list_delete_hook (ripng_distribute_update); +	/* Distribute list install. */ +	distribute_list_init(RIPNG_NODE); +	distribute_list_add_hook(ripng_distribute_update); +	distribute_list_delete_hook(ripng_distribute_update); -  /* Route-map for interface. */ -  ripng_route_map_init (); -  ripng_offset_init (); +	/* Route-map for interface. */ +	ripng_route_map_init(); +	ripng_offset_init(); -  route_map_add_hook (ripng_routemap_update); -  route_map_delete_hook (ripng_routemap_update); +	route_map_add_hook(ripng_routemap_update); +	route_map_delete_hook(ripng_routemap_update); -  if_rmap_init (RIPNG_NODE); -  if_rmap_hook_add (ripng_if_rmap_update); -  if_rmap_hook_delete (ripng_if_rmap_update); +	if_rmap_init(RIPNG_NODE); +	if_rmap_hook_add(ripng_if_rmap_update); +	if_rmap_hook_delete(ripng_if_rmap_update);  } diff --git a/ripngd/ripngd.h b/ripngd/ripngd.h index ce8ea07a41..9a609cab8a 100644 --- a/ripngd/ripngd.h +++ b/ripngd/ripngd.h @@ -90,120 +90,115 @@  #endif /* IFMINMTU */  /* RIPng structure. */ -struct ripng  -{ -  /* RIPng socket. */ -  int sock; - -  /* RIPng Parameters.*/ -  u_char command; -  u_char version; -  unsigned long update_time; -  unsigned long timeout_time; -  unsigned long garbage_time; -  int max_mtu; -  int default_metric; -  int default_information; - -  /* Input/output buffer of RIPng. */ -  struct stream *ibuf; -  struct stream *obuf; - -  /* RIPng routing information base. */ -  struct route_table *table; - -  /* RIPng only static route information. */ -  struct route_table *route; - -  /* RIPng aggregate route information. */ -  struct route_table *aggregate; - -  /* RIPng threads. */ -  struct thread *t_read; -  struct thread *t_write; -  struct thread *t_update; -  struct thread *t_garbage; -  struct thread *t_zebra; - -  /* Triggered update hack. */ -  int trigger; -  struct thread *t_triggered_update; -  struct thread *t_triggered_interval; - -  /* RIPng ECMP flag */ -  unsigned int ecmp; - -  /* For redistribute route map. */ -  struct -  { -    char *name; -    struct route_map *map; -    int metric_config; -    u_int32_t metric; -  } route_map[ZEBRA_ROUTE_MAX]; +struct ripng { +	/* RIPng socket. */ +	int sock; + +	/* RIPng Parameters.*/ +	u_char command; +	u_char version; +	unsigned long update_time; +	unsigned long timeout_time; +	unsigned long garbage_time; +	int max_mtu; +	int default_metric; +	int default_information; + +	/* Input/output buffer of RIPng. */ +	struct stream *ibuf; +	struct stream *obuf; + +	/* RIPng routing information base. */ +	struct route_table *table; + +	/* RIPng only static route information. */ +	struct route_table *route; + +	/* RIPng aggregate route information. */ +	struct route_table *aggregate; + +	/* RIPng threads. */ +	struct thread *t_read; +	struct thread *t_write; +	struct thread *t_update; +	struct thread *t_garbage; +	struct thread *t_zebra; + +	/* Triggered update hack. */ +	int trigger; +	struct thread *t_triggered_update; +	struct thread *t_triggered_interval; + +	/* RIPng ECMP flag */ +	unsigned int ecmp; + +	/* For redistribute route map. */ +	struct { +		char *name; +		struct route_map *map; +		int metric_config; +		u_int32_t metric; +	} route_map[ZEBRA_ROUTE_MAX];  };  /* Routing table entry. */ -struct rte -{ -  struct in6_addr addr;	/* RIPng destination prefix */ -  u_int16_t tag;		/* RIPng tag */ -  u_char prefixlen;	/* Length of the RIPng prefix */ -  u_char metric;	/* Metric of the RIPng route */ -  			/* The nexthop is stored by the structure -			 * ripng_nexthop within ripngd.c */ +struct rte { +	struct in6_addr addr; /* RIPng destination prefix */ +	u_int16_t tag;	/* RIPng tag */ +	u_char prefixlen;     /* Length of the RIPng prefix */ +	u_char metric;	/* Metric of the RIPng route */ +			      /* The nexthop is stored by the structure +			       * ripng_nexthop within ripngd.c */  };  /* RIPNG send packet. */ -struct ripng_packet -{ -  u_char command; -  u_char version; -  u_int16_t zero;  -  struct rte rte[1]; +struct ripng_packet { +	u_char command; +	u_char version; +	u_int16_t zero; +	struct rte rte[1];  };  /* Each route's information. */ -struct ripng_info -{ -  /* This route's type.  Static, ripng or aggregate. */ -  u_char type; +struct ripng_info { +	/* This route's type.  Static, ripng or aggregate. */ +	u_char type; -  /* Sub type for static route. */ -  u_char sub_type; +	/* Sub type for static route. */ +	u_char sub_type; -  /* RIPng specific information */ -  struct in6_addr nexthop;	 -  struct in6_addr from; +	/* RIPng specific information */ +	struct in6_addr nexthop; +	struct in6_addr from; -  /* Which interface does this route come from. */ -  ifindex_t ifindex; +	/* Which interface does this route come from. */ +	ifindex_t ifindex; -  /* Metric of this route.  */ -  u_char metric;		 +	/* Metric of this route.  */ +	u_char metric; -  /* Tag field of RIPng packet.*/ -  u_int16_t tag;		 +	/* Tag field of RIPng packet.*/ +	u_int16_t tag; -  /* For aggregation. */ -  unsigned int suppress; +	/* For aggregation. */ +	unsigned int suppress; -  /* Flags of RIPng route. */ +/* Flags of RIPng route. */  #define RIPNG_RTF_FIB      1  #define RIPNG_RTF_CHANGED  2 -  u_char flags; +	u_char flags; -  /* Garbage collect timer. */ -  struct thread *t_timeout; -  struct thread *t_garbage_collect; +	/* Garbage collect timer. */ +	struct thread *t_timeout; +	struct thread *t_garbage_collect; -  /* Route-map features - this variables can be changed. */ -  struct in6_addr nexthop_out; -  u_char metric_set; -  u_char metric_out; -  u_int16_t tag_out; +	/* Route-map features - this variables can be changed. */ +	struct in6_addr nexthop_out; +	u_char metric_set; +	u_char metric_out; +	u_int16_t tag_out; -  struct route_node *rp; +	struct route_node *rp;  };  #ifdef notyet @@ -236,38 +231,37 @@ struct ripng_tag  #endif /* not yet */  typedef enum { -  RIPNG_NO_SPLIT_HORIZON = 0, -  RIPNG_SPLIT_HORIZON, -  RIPNG_SPLIT_HORIZON_POISONED_REVERSE +	RIPNG_NO_SPLIT_HORIZON = 0, +	RIPNG_SPLIT_HORIZON, +	RIPNG_SPLIT_HORIZON_POISONED_REVERSE  } split_horizon_policy_t;  /* RIPng specific interface configuration. */ -struct ripng_interface -{ -  /* RIPng is enabled on this interface. */ -  int enable_network; -  int enable_interface; - -  /* RIPng is running on this interface. */ -  int running; - -  /* Split horizon flag. */ -  split_horizon_policy_t split_horizon; -  split_horizon_policy_t split_horizon_default; -   -  /* For filter type slot. */ +struct ripng_interface { +	/* RIPng is enabled on this interface. */ +	int enable_network; +	int enable_interface; + +	/* RIPng is running on this interface. */ +	int running; + +	/* Split horizon flag. */ +	split_horizon_policy_t split_horizon; +	split_horizon_policy_t split_horizon_default; + +/* For filter type slot. */  #define RIPNG_FILTER_IN  0  #define RIPNG_FILTER_OUT 1  #define RIPNG_FILTER_MAX 2 -  /* Access-list. */ -  struct access_list *list[RIPNG_FILTER_MAX]; +	/* Access-list. */ +	struct access_list *list[RIPNG_FILTER_MAX]; -  /* Prefix-list. */ -  struct prefix_list *prefix[RIPNG_FILTER_MAX]; +	/* Prefix-list. */ +	struct prefix_list *prefix[RIPNG_FILTER_MAX]; -  /* Route-map. */ -  struct route_map *routemap[RIPNG_FILTER_MAX]; +	/* Route-map. */ +	struct route_map *routemap[RIPNG_FILTER_MAX];  #ifdef notyet  #if 0 @@ -276,63 +270,60 @@ struct ripng_interface  #endif /* 0 */  #endif /* notyet */ -  /* Default information originate. */ -  u_char default_originate; +	/* Default information originate. */ +	u_char default_originate; -  /* Default information only. */ -  u_char default_only; +	/* Default information only. */ +	u_char default_only; -  /* Wake up thread. */ -  struct thread *t_wakeup; +	/* Wake up thread. */ +	struct thread *t_wakeup; -  /* Passive interface. */ -  int passive; +	/* Passive interface. */ +	int passive;  };  /* RIPng peer information. */ -struct ripng_peer -{ -  /* Peer address. */ -  struct in6_addr addr; +struct ripng_peer { +	/* Peer address. */ +	struct in6_addr addr; -  /* Peer RIPng tag value. */ -  int domain; +	/* Peer RIPng tag value. */ +	int domain; -  /* Last update time. */ -  time_t uptime; +	/* Last update time. */ +	time_t uptime; -  /* Peer RIP version. */ -  u_char version; +	/* Peer RIP version. */ +	u_char version; -  /* Statistics. */ -  int recv_badpackets; -  int recv_badroutes; +	/* Statistics. */ +	int recv_badpackets; +	int recv_badroutes; -  /* Timeout thread. */ -  struct thread *t_timeout; +	/* Timeout thread. */ +	struct thread *t_timeout;  };  /* All RIPng events. */ -enum ripng_event -{ -  RIPNG_READ, -  RIPNG_ZEBRA, -  RIPNG_REQUEST_EVENT, -  RIPNG_UPDATE_EVENT, -  RIPNG_TRIGGERED_UPDATE, +enum ripng_event { +	RIPNG_READ, +	RIPNG_ZEBRA, +	RIPNG_REQUEST_EVENT, +	RIPNG_UPDATE_EVENT, +	RIPNG_TRIGGERED_UPDATE,  };  /* RIPng timer on/off macro. */  #define RIPNG_TIMER_ON(T,F,V) thread_add_timer (master, (F), rinfo, (V), &(T)) -#define RIPNG_TIMER_OFF(T) \ -do { \ -   if (T) \ -     { \ -       thread_cancel(T); \ -       (T) = NULL; \ -     } \ -} while (0) +#define RIPNG_TIMER_OFF(T)                                                     \ +	do {                                                                   \ +		if (T) {                                                       \ +			thread_cancel(T);                                      \ +			(T) = NULL;                                            \ +		}                                                              \ +	} while (0)  /* Extern variables. */  extern struct ripng *ripng; @@ -340,85 +331,85 @@ extern struct ripng *ripng;  extern struct thread_master *master;  /* Prototypes. */ -extern void ripng_init (void); -extern void ripng_reset (void); -extern void ripng_clean (void); -extern void ripng_clean_network (void); -extern void ripng_interface_clean (void); -extern void ripng_interface_reset (void); -extern void ripng_passive_interface_clean (void); -extern void ripng_if_init (void); -extern void ripng_route_map_init (void); -extern void ripng_route_map_reset (void); -extern void ripng_terminate (void); - /* zclient_init() is done by ripng_zebra.c:zebra_init() */ +extern void ripng_init(void); +extern void ripng_reset(void); +extern void ripng_clean(void); +extern void ripng_clean_network(void); +extern void ripng_interface_clean(void); +extern void ripng_interface_reset(void); +extern void ripng_passive_interface_clean(void); +extern void ripng_if_init(void); +extern void ripng_route_map_init(void); +extern void ripng_route_map_reset(void); +extern void ripng_terminate(void); +/* zclient_init() is done by ripng_zebra.c:zebra_init() */  extern void zebra_init(struct thread_master *); -extern void ripng_zebra_stop (void); -extern void ripng_zclient_reset (void); -extern void ripng_offset_init (void); - -extern int config_write_ripng_offset_list (struct vty *); - -extern void ripng_peer_init (void); -extern void ripng_peer_update (struct sockaddr_in6 *, u_char); -extern void ripng_peer_bad_route (struct sockaddr_in6 *); -extern void ripng_peer_bad_packet (struct sockaddr_in6 *); -extern void ripng_peer_display (struct vty *); -extern struct ripng_peer *ripng_peer_lookup (struct in6_addr *); -extern struct ripng_peer *ripng_peer_lookup_next (struct in6_addr *); - -extern int ripng_offset_list_apply_in (struct prefix_ipv6 *, -                                       struct interface *, u_char *); -extern int ripng_offset_list_apply_out (struct prefix_ipv6 *, -                                        struct interface *, u_char *); -extern void ripng_offset_clean (void); - -extern struct ripng_info * ripng_info_new (void); -extern void ripng_info_free (struct ripng_info *rinfo); -extern void ripng_event (enum ripng_event, int); -extern int ripng_request (struct interface *ifp); -extern void ripng_redistribute_add (int, int, struct prefix_ipv6 *, -                                    ifindex_t, struct in6_addr *, route_tag_t); -extern void ripng_redistribute_delete (int, int, struct prefix_ipv6 *, -                                       ifindex_t); -extern void ripng_redistribute_withdraw (int type); - -extern void ripng_distribute_update_interface (struct interface *); -extern void ripng_if_rmap_update_interface (struct interface *); - -extern void ripng_zebra_ipv6_add (struct route_node *); -extern void ripng_zebra_ipv6_delete (struct route_node *); - -extern void ripng_redistribute_clean (void); -extern int ripng_redistribute_check (int); -extern void ripng_redistribute_write (struct vty *, int); - -extern int ripng_write_rte (int num, struct stream *s, struct prefix_ipv6 *p, -                            struct in6_addr *nexthop, -                            u_int16_t tag, u_char metric); -extern int ripng_send_packet (caddr_t buf, int bufsize, -                              struct sockaddr_in6 *to, struct interface *ifp); - -extern void ripng_packet_dump (struct ripng_packet *packet, int size, -                               const char *sndrcv); - -extern int ripng_interface_up (int command, struct zclient *, zebra_size_t, -    vrf_id_t); -extern int ripng_interface_down (int command, struct zclient *, zebra_size_t, -    vrf_id_t); -extern int ripng_interface_add (int command, struct zclient *, zebra_size_t, -    vrf_id_t); -extern int ripng_interface_delete (int command, struct zclient *, zebra_size_t, -    vrf_id_t); -extern int ripng_interface_address_add (int command, struct zclient *, zebra_size_t, -    vrf_id_t); -extern int ripng_interface_address_delete (int command, struct zclient *, zebra_size_t, -    vrf_id_t); - -extern int ripng_network_write (struct vty *, int); - -extern struct ripng_info *ripng_ecmp_add (struct ripng_info *); -extern struct ripng_info *ripng_ecmp_replace (struct ripng_info *); -extern struct ripng_info *ripng_ecmp_delete (struct ripng_info *); +extern void ripng_zebra_stop(void); +extern void ripng_zclient_reset(void); +extern void ripng_offset_init(void); + +extern int config_write_ripng_offset_list(struct vty *); + +extern void ripng_peer_init(void); +extern void ripng_peer_update(struct sockaddr_in6 *, u_char); +extern void ripng_peer_bad_route(struct sockaddr_in6 *); +extern void ripng_peer_bad_packet(struct sockaddr_in6 *); +extern void ripng_peer_display(struct vty *); +extern struct ripng_peer *ripng_peer_lookup(struct in6_addr *); +extern struct ripng_peer *ripng_peer_lookup_next(struct in6_addr *); + +extern int ripng_offset_list_apply_in(struct prefix_ipv6 *, struct interface *, +				      u_char *); +extern int ripng_offset_list_apply_out(struct prefix_ipv6 *, struct interface *, +				       u_char *); +extern void ripng_offset_clean(void); + +extern struct ripng_info *ripng_info_new(void); +extern void ripng_info_free(struct ripng_info *rinfo); +extern void ripng_event(enum ripng_event, int); +extern int ripng_request(struct interface *ifp); +extern void ripng_redistribute_add(int, int, struct prefix_ipv6 *, ifindex_t, +				   struct in6_addr *, route_tag_t); +extern void ripng_redistribute_delete(int, int, struct prefix_ipv6 *, +				      ifindex_t); +extern void ripng_redistribute_withdraw(int type); + +extern void ripng_distribute_update_interface(struct interface *); +extern void ripng_if_rmap_update_interface(struct interface *); + +extern void ripng_zebra_ipv6_add(struct route_node *); +extern void ripng_zebra_ipv6_delete(struct route_node *); + +extern void ripng_redistribute_clean(void); +extern int ripng_redistribute_check(int); +extern void ripng_redistribute_write(struct vty *, int); + +extern int ripng_write_rte(int num, struct stream *s, struct prefix_ipv6 *p, +			   struct in6_addr *nexthop, u_int16_t tag, +			   u_char metric); +extern int ripng_send_packet(caddr_t buf, int bufsize, struct sockaddr_in6 *to, +			     struct interface *ifp); + +extern void ripng_packet_dump(struct ripng_packet *packet, int size, +			      const char *sndrcv); + +extern int ripng_interface_up(int command, struct zclient *, zebra_size_t, +			      vrf_id_t); +extern int ripng_interface_down(int command, struct zclient *, zebra_size_t, +				vrf_id_t); +extern int ripng_interface_add(int command, struct zclient *, zebra_size_t, +			       vrf_id_t); +extern int ripng_interface_delete(int command, struct zclient *, zebra_size_t, +				  vrf_id_t); +extern int ripng_interface_address_add(int command, struct zclient *, +				       zebra_size_t, vrf_id_t); +extern int ripng_interface_address_delete(int command, struct zclient *, +					  zebra_size_t, vrf_id_t); + +extern int ripng_network_write(struct vty *, int); + +extern struct ripng_info *ripng_ecmp_add(struct ripng_info *); +extern struct ripng_info *ripng_ecmp_replace(struct ripng_info *); +extern struct ripng_info *ripng_ecmp_delete(struct ripng_info *);  #endif /* _ZEBRA_RIPNG_RIPNGD_H */  | 
