Merge branch 'cmaster' of ssh://stash.cumulusnetworks.com:7999/quag/quagga into cmaster

This commit is contained in:
vivek 2015-12-08 17:01:20 -08:00
commit 3d63d59fd1
22 changed files with 156 additions and 304 deletions

View File

@ -1,7 +1,7 @@
## Process this file with automake to produce Makefile.in.
INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" -DMULTIPATH_NUM=@MULTIPATH_NUM@
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
INSTALL_SDATA=@INSTALL@ -m 600
AM_CFLAGS = $(PICFLAGS) $(WERROR)

View File

@ -83,11 +83,11 @@ bgp_maximum_paths_unset (struct bgp *bgp, afi_t afi, safi_t safi,
switch (peertype)
{
case BGP_PEER_IBGP:
bgp->maxpaths[afi][safi].maxpaths_ibgp = BGP_DEFAULT_MAXPATHS;
bgp->maxpaths[afi][safi].maxpaths_ibgp = MULTIPATH_NUM;
bgp->maxpaths[afi][safi].ibgp_flags = 0;
break;
case BGP_PEER_EBGP:
bgp->maxpaths[afi][safi].maxpaths_ebgp = BGP_DEFAULT_MAXPATHS;
bgp->maxpaths[afi][safi].maxpaths_ebgp = MULTIPATH_NUM;
break;
default:
return -1;
@ -430,7 +430,7 @@ bgp_info_mpath_update (struct bgp_node *rn, struct bgp_info *new_best,
char path_buf[PATH_ADDPATH_STR_BUFFER];
mpath_changed = 0;
maxpaths = BGP_DEFAULT_MAXPATHS;
maxpaths = MULTIPATH_NUM;
mpath_count = 0;
cur_mpath = NULL;
old_mpath_count = 0;

View File

@ -24,12 +24,6 @@
#ifndef _QUAGGA_BGP_MPATH_H
#define _QUAGGA_BGP_MPATH_H
/* Limit on number of configured maxpaths */
#define BGP_MAXIMUM_MAXPATHS 255
/* BGP default maximum-paths */
#define BGP_DEFAULT_MAXPATHS MULTIPATH_NUM
/* Supplemental information linked to bgp_info for keeping track of
* multipath selections, lazily allocated to save memory
*/

View File

@ -992,7 +992,7 @@ bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths,
if (set)
{
VTY_GET_INTEGER_RANGE ("maximum-paths", maxpaths, mpaths, 1,
BGP_MAXIMUM_MAXPATHS);
MULTIPATH_NUM);
ret = bgp_maximum_paths_set (bgp, afi, safi, peer_type, maxpaths,
options);
}
@ -1011,11 +1011,6 @@ bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths,
bgp_recalculate_all_bestpaths (bgp);
if (maxpaths > MULTIPATH_NUM)
vty_out (vty,
"%% Warning: maximum-paths set to %d is greater than %d that zebra is compiled to support%s",
maxpaths, MULTIPATH_NUM, VTY_NEWLINE);
return CMD_SUCCESS;
}
@ -1385,7 +1380,7 @@ DEFUN (no_bgp_coalesce_time,
/* Maximum-paths configuration */
DEFUN (bgp_maxpaths,
bgp_maxpaths_cmd,
"maximum-paths <1-255>",
"maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM),
"Forward packets over multiple paths\n"
"Number of paths\n")
{
@ -1394,7 +1389,7 @@ DEFUN (bgp_maxpaths,
DEFUN (bgp_maxpaths_ibgp,
bgp_maxpaths_ibgp_cmd,
"maximum-paths ibgp <1-255>",
"maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM),
"Forward packets over multiple paths\n"
"iBGP-multipath\n"
"Number of paths\n")
@ -1404,7 +1399,7 @@ DEFUN (bgp_maxpaths_ibgp,
DEFUN (bgp_maxpaths_ibgp_cluster,
bgp_maxpaths_ibgp_cluster_cmd,
"maximum-paths ibgp <1-255> equal-cluster-length",
"maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length",
"Forward packets over multiple paths\n"
"iBGP-multipath\n"
"Number of paths\n"
@ -1426,7 +1421,7 @@ DEFUN (no_bgp_maxpaths,
ALIAS (no_bgp_maxpaths,
no_bgp_maxpaths_arg_cmd,
"no maximum-paths <1-255>",
"no maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM),
NO_STR
"Forward packets over multiple paths\n"
"Number of paths\n")
@ -1444,7 +1439,7 @@ DEFUN (no_bgp_maxpaths_ibgp,
ALIAS (no_bgp_maxpaths_ibgp,
no_bgp_maxpaths_ibgp_arg_cmd,
"no maximum-paths ibgp <1-255>",
"no maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM),
NO_STR
"Forward packets over multiple paths\n"
"iBGP-multipath\n"
@ -1452,7 +1447,7 @@ ALIAS (no_bgp_maxpaths_ibgp,
ALIAS (no_bgp_maxpaths_ibgp,
no_bgp_maxpaths_ibgp_cluster_cmd,
"no maximum-paths ibgp <1-255> equal-cluster-length",
"no maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length",
NO_STR
"Forward packets over multiple paths\n"
"iBGP-multipath\n"
@ -1463,14 +1458,14 @@ int
bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi,
safi_t safi, int *write)
{
if (bgp->maxpaths[afi][safi].maxpaths_ebgp != BGP_DEFAULT_MAXPATHS)
if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM)
{
bgp_config_write_family_header (vty, afi, safi, write);
vty_out (vty, " maximum-paths %d%s",
bgp->maxpaths[afi][safi].maxpaths_ebgp, VTY_NEWLINE);
}
if (bgp->maxpaths[afi][safi].maxpaths_ibgp != BGP_DEFAULT_MAXPATHS)
if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM)
{
bgp_config_write_family_header (vty, afi, safi, write);
vty_out (vty, " maximum-paths ibgp %d",
@ -4320,7 +4315,7 @@ DEFUN (neighbor_ebgp_multihop,
DEFUN (neighbor_ebgp_multihop_ttl,
neighbor_ebgp_multihop_ttl_cmd,
NEIGHBOR_CMD2 "ebgp-multihop <1-255>",
NEIGHBOR_CMD2 "ebgp-multihop " CMD_RANGE_STR(1, MULTIPATH_NUM),
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2
"Allow EBGP neighbors not on directly connected networks\n"
@ -4342,7 +4337,7 @@ DEFUN (no_neighbor_ebgp_multihop,
ALIAS (no_neighbor_ebgp_multihop,
no_neighbor_ebgp_multihop_ttl_cmd,
NO_NEIGHBOR_CMD2 "ebgp-multihop <1-255>",
NO_NEIGHBOR_CMD2 "ebgp-multihop " CMD_RANGE_STR(1, MULTIPATH_NUM),
NO_STR
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2

View File

@ -62,22 +62,22 @@ struct stream *bgp_ifindices_buf = NULL;
1. maintain a linked-list and free it after zapi_*_route call
2. use an array to avoid number of mallocs.
Number of supported next-hops are finite, use of arrays should be ok. */
struct attr attr_cp[BGP_MAXIMUM_MAXPATHS];
struct attr_extra attr_extra_cp[BGP_MAXIMUM_MAXPATHS];
struct attr attr_cp[MULTIPATH_NUM];
struct attr_extra attr_extra_cp[MULTIPATH_NUM];
int attr_index = 0;
/* Once per address-family initialization of the attribute array */
#define BGP_INFO_ATTR_BUF_INIT()\
do {\
memset(attr_cp, 0, BGP_MAXIMUM_MAXPATHS * sizeof(struct attr));\
memset(attr_extra_cp, 0, BGP_MAXIMUM_MAXPATHS * sizeof(struct attr_extra));\
memset(attr_cp, 0, MULTIPATH_NUM * sizeof(struct attr));\
memset(attr_extra_cp, 0, MULTIPATH_NUM * sizeof(struct attr_extra));\
attr_index = 0;\
} while (0)
#define BGP_INFO_ATTR_BUF_COPY(info_src, info_dst)\
do { \
*info_dst = *info_src; \
assert(attr_index != BGP_MAXIMUM_MAXPATHS);\
assert(attr_index != MULTIPATH_NUM);\
attr_cp[attr_index].extra = &attr_extra_cp[attr_index]; \
bgp_attr_dup (&attr_cp[attr_index], info_src->attr); \
bgp_attr_deep_dup (&attr_cp[attr_index], info_src->attr); \

View File

@ -2728,8 +2728,8 @@ bgp_create (as_t *as, const char *name)
bgp->rib[afi][safi] = bgp_table_init (afi, safi);
/* Enable maximum-paths */
bgp_maximum_paths_set (bgp, afi, safi, BGP_PEER_EBGP, BGP_DEFAULT_MAXPATHS, 0);
bgp_maximum_paths_set (bgp, afi, safi, BGP_PEER_IBGP, BGP_DEFAULT_MAXPATHS, 0);
bgp_maximum_paths_set (bgp, afi, safi, BGP_PEER_EBGP, MULTIPATH_NUM, 0);
bgp_maximum_paths_set (bgp, afi, safi, BGP_PEER_IBGP, MULTIPATH_NUM, 0);
}
bgp->v_update_delay = BGP_UPDATE_DELAY_DEF;

View File

@ -412,14 +412,14 @@ AC_DEFINE_UNQUOTED(CONFIGFILE_MASK, ${enable_configfile_mask}, Mask for config f
enable_logfile_mask=${enable_logfile_mask:-0600}
AC_DEFINE_UNQUOTED(LOGFILE_MASK, ${enable_logfile_mask}, Mask for log files)
MULTIPATH_NUM=1
MPATH_NUM=1
case "${enable_multipath}" in
0)
MULTIPATH_NUM=64
MPATH_NUM=64
;;
[[1-9]|[1-9][0-9]])
MULTIPATH_NUM="${enable_multipath}"
MPATH_NUM="${enable_multipath}"
;;
"")
;;
@ -428,7 +428,7 @@ case "${enable_multipath}" in
;;
esac
AC_SUBST(MULTIPATH_NUM)
AC_DEFINE_UNQUOTED(MULTIPATH_NUM, $MPATH_NUM, Maximum number of paths for a route)
dnl -----------------------------------
dnl Add extra version string to package

View File

@ -437,6 +437,17 @@ struct cmd_token
#endif /* VTYSH_EXTRACT_PL */
/* Some macroes */
/*
* Sometimes #defines create maximum values that
* need to have strings created from them that
* allow the parser to match against them.
* These macros allow that.
*/
#define CMD_CREATE_STR(s) CMD_CREATE_STR_HELPER(s)
#define CMD_CREATE_STR_HELPER(s) #s
#define CMD_RANGE_STR(a,s) "<" CMD_CREATE_STR(a) "-" CMD_CREATE_STR(s) ">"
#define CMD_OPTION(S) ((S[0]) == '[')
#define CMD_VARIABLE(S) (((S[0]) >= 'A' && (S[0]) <= 'Z') || ((S[0]) == '<'))
#define CMD_VARARG(S) ((S[0]) == '.')

View File

@ -50,23 +50,19 @@ nexthop_same_no_recurse (struct nexthop *next1, struct nexthop *next2)
return 0;
break;
case NEXTHOP_TYPE_IFINDEX:
case NEXTHOP_TYPE_IFNAME:
if (next1->ifindex != next2->ifindex)
return 0;
break;
#ifdef HAVE_IPV6
case NEXTHOP_TYPE_IPV6:
if (! IPV6_ADDR_SAME (&next1->gate.ipv6, &next2->gate.ipv6))
return 0;
break;
case NEXTHOP_TYPE_IPV6_IFINDEX:
case NEXTHOP_TYPE_IPV6_IFNAME:
if (! IPV6_ADDR_SAME (&next1->gate.ipv6, &next2->gate.ipv6))
return 0;
if (next1->ifindex != next2->ifindex)
return 0;
break;
#endif /* HAVE_IPV6 */
default:
/* do nothing */
break;
@ -132,8 +128,6 @@ copy_nexthops (struct nexthop **tnh, struct nexthop *nh)
nexthop->flags = nh->flags;
nexthop->type = nh->type;
nexthop->ifindex = nh->ifindex;
if (nh->ifname)
nexthop->ifname = XSTRDUP(0, nh->ifname);
memcpy(&(nexthop->gate), &(nh->gate), sizeof(union g_addr));
memcpy(&(nexthop->src), &(nh->src), sizeof(union g_addr));
nexthop_add(tnh, nexthop);
@ -147,8 +141,6 @@ copy_nexthops (struct nexthop **tnh, struct nexthop *nh)
void
nexthop_free (struct nexthop *nexthop)
{
if (nexthop->ifname)
XFREE (0, nexthop->ifname);
if (nexthop->resolved)
nexthops_free(nexthop->resolved);
XFREE (MTYPE_NEXTHOP, nexthop);

View File

@ -34,13 +34,10 @@ union g_addr {
enum nexthop_types_t
{
NEXTHOP_TYPE_IFINDEX = 1, /* Directly connected. */
NEXTHOP_TYPE_IFNAME, /* Interface route. */
NEXTHOP_TYPE_IPV4, /* IPv4 nexthop. */
NEXTHOP_TYPE_IPV4_IFINDEX, /* IPv4 nexthop with ifindex. */
NEXTHOP_TYPE_IPV4_IFNAME, /* IPv4 nexthop with ifname. */
NEXTHOP_TYPE_IPV6, /* IPv6 nexthop. */
NEXTHOP_TYPE_IPV6_IFINDEX, /* IPv6 nexthop with ifindex. */
NEXTHOP_TYPE_IPV6_IFNAME, /* IPv6 nexthop with ifname. */
NEXTHOP_TYPE_BLACKHOLE, /* Null0 nexthop. */
};
@ -51,7 +48,6 @@ struct nexthop
struct nexthop *prev;
/* Interface index. */
char *ifname;
unsigned int ifindex;
enum nexthop_types_t type;

View File

@ -499,15 +499,12 @@ extern const char *zserv_command_string (unsigned int command);
/* Zebra nexthop flags. */
#define ZEBRA_NEXTHOP_IFINDEX 1
#define ZEBRA_NEXTHOP_IFNAME 2
#define ZEBRA_NEXTHOP_IPV4 3
#define ZEBRA_NEXTHOP_IPV4_IFINDEX 4
#define ZEBRA_NEXTHOP_IPV4_IFNAME 5
#define ZEBRA_NEXTHOP_IPV6 6
#define ZEBRA_NEXTHOP_IPV6_IFINDEX 7
#define ZEBRA_NEXTHOP_IPV6_IFNAME 8
#define ZEBRA_NEXTHOP_BLACKHOLE 9
#define ZEBRA_NEXTHOP_IPV4_ONLINK 10
#define ZEBRA_NEXTHOP_IPV4 2
#define ZEBRA_NEXTHOP_IPV4_IFINDEX 3
#define ZEBRA_NEXTHOP_IPV6 4
#define ZEBRA_NEXTHOP_IPV6_IFINDEX 5
#define ZEBRA_NEXTHOP_BLACKHOLE 6
#define ZEBRA_NEXTHOP_IPV4_ONLINK 7
#ifndef INADDR_LOOPBACK
#define INADDR_LOOPBACK 0x7f000001 /* Internet address 127.0.0.1. */

View File

@ -113,8 +113,8 @@ bgp_create_fake (as_t *as, const char *name)
bgp->route[afi][safi] = bgp_table_init (afi, safi);
bgp->aggregate[afi][safi] = bgp_table_init (afi, safi);
bgp->rib[afi][safi] = bgp_table_init (afi, safi);
bgp->maxpaths[afi][safi].maxpaths_ebgp = BGP_DEFAULT_MAXPATHS;
bgp->maxpaths[afi][safi].maxpaths_ibgp = BGP_DEFAULT_MAXPATHS;
bgp->maxpaths[afi][safi].maxpaths_ebgp = MULTIPATH_NUM;
bgp->maxpaths[afi][safi].maxpaths_ibgp = MULTIPATH_NUM;
}
bgp->default_local_pref = BGP_DEFAULT_LOCAL_PREF;
@ -171,9 +171,9 @@ run_bgp_cfg_maximum_paths (testcase_t *t)
api_result = bgp_maximum_paths_unset (bgp, afi, safi, BGP_PEER_IBGP);
EXPECT_TRUE (api_result == 0, test_result);
EXPECT_TRUE ((bgp->maxpaths[afi][safi].maxpaths_ebgp ==
BGP_DEFAULT_MAXPATHS), test_result);
MULTIPATH_NUM), test_result);
EXPECT_TRUE ((bgp->maxpaths[afi][safi].maxpaths_ibgp ==
BGP_DEFAULT_MAXPATHS), test_result);
MULTIPATH_NUM), test_result);
}
return test_result;

View File

@ -1,7 +1,7 @@
## Process this file with automake to produce Makefile.in.
INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" -DMULTIPATH_NUM=@MULTIPATH_NUM@
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
INSTALL_SDATA=@INSTALL@ -m 600
LIB_IPV6 = @LIB_IPV6@

View File

@ -186,23 +186,22 @@ struct static_route
/* Flag for this static route's type. */
u_char type;
#define STATIC_IPV4_GATEWAY 1
#define STATIC_IPV4_IFNAME 2
#define STATIC_IFINDEX 1
#define STATIC_IPV4_GATEWAY 2
#define STATIC_IPV4_BLACKHOLE 3
#define STATIC_IPV6_GATEWAY 4
#define STATIC_IPV6_GATEWAY_IFNAME 5
#define STATIC_IPV6_IFNAME 6
#define STATIC_IPV6_GATEWAY_IFINDEX 5
/*
* Nexthop value.
*
* Under IPv4 addr and ifname are
* Under IPv4 addr and ifindex are
* used independentyly.
* STATIC_IPV4_GATEWAY uses addr
* STATIC_IPV4_IFNAME uses ifname
* STATIC_IFINDEX uses ifindex
*/
union g_addr addr;
char *ifname;
unsigned int ifindex;
/* bit flags */
u_char flags;
@ -380,7 +379,6 @@ typedef enum
} rib_update_event_t;
extern struct nexthop *rib_nexthop_ifindex_add (struct rib *, unsigned int);
extern struct nexthop *rib_nexthop_ifname_add (struct rib *, char *);
extern struct nexthop *rib_nexthop_blackhole_add (struct rib *);
extern struct nexthop *rib_nexthop_ipv4_add (struct rib *, struct in_addr *,
struct in_addr *);
@ -409,9 +407,6 @@ extern struct nexthop *rib_nexthop_ipv6_add (struct rib *, struct in6_addr *);
extern struct nexthop *rib_nexthop_ipv6_ifindex_add (struct rib *rib,
struct in6_addr *ipv6,
unsigned int ifindex);
extern struct nexthop *rib_nexthop_ipv6_ifname_add (struct rib *rib,
struct in6_addr *ipv6,
char *ifname);
extern struct zebra_vrf *zebra_vrf_lookup (vrf_id_t vrf_id);
extern struct zebra_vrf *zebra_vrf_alloc (vrf_id_t);
@ -453,11 +448,11 @@ extern void rib_queue_add (struct zebra_t *zebra, struct route_node *rn);
extern int
static_add_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname,
static_add_ipv4 (struct prefix *p, struct in_addr *gate, unsigned int ifindex,
u_char flags, u_short tag, u_char distance, vrf_id_t vrf_id);
extern int
static_delete_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname,
static_delete_ipv4 (struct prefix *p, struct in_addr *gate, unsigned int ifindex,
u_short tag, u_char distance, vrf_id_t vrf_id);
extern int
@ -478,7 +473,7 @@ extern struct route_table *rib_table_ipv6;
extern int
static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
const char *ifname, u_char flags, u_short tag,
unsigned int ifindex, u_char flags, u_short tag,
u_char distance, vrf_id_t vrf_id);
extern int
@ -487,7 +482,7 @@ rib_add_ipv6_multipath (struct prefix *, struct rib *, safi_t,
extern int
static_delete_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
const char *ifname, u_short tag, u_char distance,
unsigned int ifindex, u_short tag, u_char distance,
vrf_id_t vrf_id);
extern int rib_gc_dest (struct route_node *rn);

View File

@ -1504,7 +1504,6 @@ _netlink_route_build_singlepath(
if (rtmsg->rtm_family == AF_INET &&
(nexthop->type == NEXTHOP_TYPE_IPV6
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX))
{
char buf[16] = "169.254.0.1";
@ -1555,9 +1554,7 @@ _netlink_route_build_singlepath(
inet_ntoa (nexthop->gate.ipv4),
nexthop->ifindex);
}
#ifdef HAVE_IPV6
if (nexthop->type == NEXTHOP_TYPE_IPV6
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
{
addattr_l (nlmsg, req_size, RTA_GATEWAY,
@ -1580,9 +1577,7 @@ _netlink_route_build_singlepath(
inet6_ntoa (nexthop->gate.ipv6),
nexthop->ifindex);
}
#endif /* HAVE_IPV6 */
if (nexthop->type == NEXTHOP_TYPE_IFINDEX
|| nexthop->type == NEXTHOP_TYPE_IFNAME
|| nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX)
{
addattr32 (nlmsg, req_size, RTA_OIF, nexthop->ifindex);
@ -1602,8 +1597,7 @@ _netlink_route_build_singlepath(
"nexthop via if %u", routedesc, nexthop->ifindex);
}
if (nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
if (nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
{
addattr32 (nlmsg, req_size, RTA_OIF, nexthop->ifindex);
@ -1656,7 +1650,6 @@ _netlink_route_build_multipath(
if (rtmsg->rtm_family == AF_INET &&
(nexthop->type == NEXTHOP_TYPE_IPV6
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX))
{
char buf[16] = "169.254.0.1";
@ -1705,9 +1698,7 @@ _netlink_route_build_multipath(
inet_ntoa (nexthop->gate.ipv4),
nexthop->ifindex);
}
#ifdef HAVE_IPV6
if (nexthop->type == NEXTHOP_TYPE_IPV6
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
{
rta_addattr_l (rta, NL_PKT_BUF_SIZE, RTA_GATEWAY,
@ -1726,11 +1717,9 @@ _netlink_route_build_multipath(
inet6_ntoa (nexthop->gate.ipv6),
nexthop->ifindex);
}
#endif /* HAVE_IPV6 */
/* ifindex */
if (nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX
|| nexthop->type == NEXTHOP_TYPE_IFINDEX
|| nexthop->type == NEXTHOP_TYPE_IFNAME)
|| nexthop->type == NEXTHOP_TYPE_IFINDEX)
{
rtnh->rtnh_ifindex = nexthop->ifindex;
@ -1743,8 +1732,7 @@ _netlink_route_build_multipath(
zlog_debug("netlink_route_multipath() (%s): "
"nexthop via if %u", routedesc, nexthop->ifindex);
}
else if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
else if (nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
{
rtnh->rtnh_ifindex = nexthop->ifindex;

View File

@ -123,7 +123,6 @@ kernel_rtm_ipv4 (int cmd, struct prefix *p, struct rib *rib, int family)
gate = 1;
}
if (nexthop->type == NEXTHOP_TYPE_IFINDEX
|| nexthop->type == NEXTHOP_TYPE_IFNAME
|| nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX)
ifindex = nexthop->ifindex;
if (nexthop->type == NEXTHOP_TYPE_BLACKHOLE)
@ -388,15 +387,12 @@ kernel_rtm_ipv6_multipath (int cmd, struct prefix *p, struct rib *rib,
))
{
if (nexthop->type == NEXTHOP_TYPE_IPV6
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
{
sin_gate.sin6_addr = nexthop->gate.ipv6;
gate = 1;
}
if (nexthop->type == NEXTHOP_TYPE_IFINDEX
|| nexthop->type == NEXTHOP_TYPE_IFNAME
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
ifindex = nexthop->ifindex;

View File

@ -176,17 +176,13 @@ netlink_route_info_add_nh (netlink_route_info_t *ri, struct nexthop *nexthop,
src = &nexthop->src;
}
#ifdef HAVE_IPV6
if (nexthop->type == NEXTHOP_TYPE_IPV6
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
{
nhi.gateway = &nexthop->gate;
}
#endif /* HAVE_IPV6 */
if (nexthop->type == NEXTHOP_TYPE_IFINDEX
|| nexthop->type == NEXTHOP_TYPE_IFNAME)
if (nexthop->type == NEXTHOP_TYPE_IFINDEX)
{
if (nexthop->src.ipv4.s_addr)
src = &nexthop->src;

View File

@ -147,8 +147,6 @@ rib_copy_nexthops (struct rib *rib, struct nexthop *nh)
nexthop->flags = nh->flags;
nexthop->type = nh->type;
nexthop->ifindex = nh->ifindex;
if (nh->ifname)
nexthop->ifname = XSTRDUP(0, nh->ifname);
memcpy(&(nexthop->gate), &(nh->gate), sizeof(union g_addr));
memcpy(&(nexthop->src), &(nh->src), sizeof(union g_addr));
rib_nexthop_add(rib, nexthop);
@ -185,20 +183,6 @@ rib_nexthop_ifindex_add (struct rib *rib, unsigned int ifindex)
return nexthop;
}
struct nexthop *
rib_nexthop_ifname_add (struct rib *rib, char *ifname)
{
struct nexthop *nexthop;
nexthop = nexthop_new();
nexthop->type = NEXTHOP_TYPE_IFNAME;
nexthop->ifname = XSTRDUP (0, ifname);
rib_nexthop_add (rib, nexthop);
return nexthop;
}
struct nexthop *
rib_nexthop_ipv4_add (struct rib *rib, struct in_addr *ipv4, struct in_addr *src)
{
@ -252,22 +236,6 @@ rib_nexthop_ipv6_add (struct rib *rib, struct in6_addr *ipv6)
return nexthop;
}
struct nexthop *
rib_nexthop_ipv6_ifname_add (struct rib *rib, struct in6_addr *ipv6,
char *ifname)
{
struct nexthop *nexthop;
nexthop = nexthop_new();
nexthop->type = NEXTHOP_TYPE_IPV6_IFNAME;
nexthop->gate.ipv6 = *ipv6;
nexthop->ifname = XSTRDUP (0, ifname);
rib_nexthop_add (rib, nexthop);
return nexthop;
}
struct nexthop *
rib_nexthop_ipv6_ifindex_add (struct rib *rib, struct in6_addr *ipv6,
unsigned int ifindex)
@ -445,8 +413,7 @@ nexthop_active_ipv4 (struct rib *rib, struct nexthop *nexthop, int set,
SET_FLAG (resolved_hop->flags, NEXTHOP_FLAG_ACTIVE);
/* If the resolving route specifies a gateway, use it */
if (newhop->type == NEXTHOP_TYPE_IPV4
|| newhop->type == NEXTHOP_TYPE_IPV4_IFINDEX
|| newhop->type == NEXTHOP_TYPE_IPV4_IFNAME)
|| newhop->type == NEXTHOP_TYPE_IPV4_IFINDEX)
{
resolved_hop->type = newhop->type;
resolved_hop->gate.ipv4 = newhop->gate.ipv4;
@ -468,8 +435,7 @@ nexthop_active_ipv4 (struct rib *rib, struct nexthop *nexthop, int set,
*
* On Linux, we have to set the onlink netlink flag because
* otherwise, the kernel won't accept the route. */
if (newhop->type == NEXTHOP_TYPE_IFINDEX
|| newhop->type == NEXTHOP_TYPE_IFNAME)
if (newhop->type == NEXTHOP_TYPE_IFINDEX)
{
resolved_hop->flags |= NEXTHOP_FLAG_ONLINK;
resolved_hop->type = NEXTHOP_TYPE_IPV4_IFINDEX;
@ -497,8 +463,7 @@ nexthop_active_ipv4 (struct rib *rib, struct nexthop *nexthop, int set,
SET_FLAG (resolved_hop->flags, NEXTHOP_FLAG_ACTIVE);
/* If the resolving route specifies a gateway, use it */
if (newhop->type == NEXTHOP_TYPE_IPV4
|| newhop->type == NEXTHOP_TYPE_IPV4_IFINDEX
|| newhop->type == NEXTHOP_TYPE_IPV4_IFNAME)
|| newhop->type == NEXTHOP_TYPE_IPV4_IFINDEX)
{
resolved_hop->type = newhop->type;
resolved_hop->gate.ipv4 = newhop->gate.ipv4;
@ -521,8 +486,7 @@ nexthop_active_ipv4 (struct rib *rib, struct nexthop *nexthop, int set,
* On Linux, we have to set the onlink netlink flag because
* otherwise, the kernel won't accept the route.
*/
if (newhop->type == NEXTHOP_TYPE_IFINDEX
|| newhop->type == NEXTHOP_TYPE_IFNAME)
if (newhop->type == NEXTHOP_TYPE_IFINDEX)
{
resolved_hop->flags |= NEXTHOP_FLAG_ONLINK;
resolved_hop->type = NEXTHOP_TYPE_IPV4_IFINDEX;
@ -656,8 +620,7 @@ nexthop_active_ipv6 (struct rib *rib, struct nexthop *nexthop, int set,
/* See nexthop_active_ipv4 for a description how the
* resolved nexthop is constructed. */
if (newhop->type == NEXTHOP_TYPE_IPV6
|| newhop->type == NEXTHOP_TYPE_IPV6_IFINDEX
|| newhop->type == NEXTHOP_TYPE_IPV6_IFNAME)
|| newhop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
{
resolved_hop->type = newhop->type;
resolved_hop->gate.ipv6 = newhop->gate.ipv6;
@ -669,8 +632,7 @@ nexthop_active_ipv6 (struct rib *rib, struct nexthop *nexthop, int set,
}
}
if (newhop->type == NEXTHOP_TYPE_IFINDEX
|| newhop->type == NEXTHOP_TYPE_IFNAME)
if (newhop->type == NEXTHOP_TYPE_IFINDEX)
{
resolved_hop->flags |= NEXTHOP_FLAG_ONLINK;
resolved_hop->type = NEXTHOP_TYPE_IPV6_IFINDEX;
@ -699,8 +661,7 @@ nexthop_active_ipv6 (struct rib *rib, struct nexthop *nexthop, int set,
/* See nexthop_active_ipv4 for a description how the
* resolved nexthop is constructed. */
if (newhop->type == NEXTHOP_TYPE_IPV6
|| newhop->type == NEXTHOP_TYPE_IPV6_IFINDEX
|| newhop->type == NEXTHOP_TYPE_IPV6_IFNAME)
|| newhop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
{
resolved_hop->type = newhop->type;
resolved_hop->gate.ipv6 = newhop->gate.ipv6;
@ -712,8 +673,7 @@ nexthop_active_ipv6 (struct rib *rib, struct nexthop *nexthop, int set,
}
}
if (newhop->type == NEXTHOP_TYPE_IFINDEX
|| newhop->type == NEXTHOP_TYPE_IFNAME)
if (newhop->type == NEXTHOP_TYPE_IFINDEX)
{
resolved_hop->flags |= NEXTHOP_FLAG_ONLINK;
resolved_hop->type = NEXTHOP_TYPE_IPV6_IFINDEX;
@ -1020,23 +980,6 @@ nexthop_active_check (struct route_node *rn, struct rib *rib,
else
UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE);
break;
case NEXTHOP_TYPE_IPV6_IFNAME:
family = AFI_IP6;
case NEXTHOP_TYPE_IFNAME:
ifp = if_lookup_by_name_vrf (nexthop->ifname, rib->vrf_id);
if (ifp && if_is_operative(ifp))
{
if (set)
nexthop->ifindex = ifp->ifindex;
SET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE);
}
else
{
if (set)
nexthop->ifindex = 0;
UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE);
}
break;
case NEXTHOP_TYPE_IPV4:
case NEXTHOP_TYPE_IPV4_IFINDEX:
family = AFI_IP;
@ -1108,7 +1051,8 @@ nexthop_active_check (struct route_node *rn, struct rib *rib,
{
inet_ntop (rn->p.family, &rn->p.u.prefix, buf, sizeof (buf));
zlog_debug("%u:%s/%d: Filtering out with NH out %s due to route map",
rib->vrf_id, buf, rn->p.prefixlen, nexthop->ifname);
rib->vrf_id, buf, rn->p.prefixlen,
ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
}
UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE);
}
@ -2602,8 +2546,8 @@ static_install_route (afi_t afi, safi_t safi, struct prefix *p, struct static_ro
nh_p.u.prefix4 = si->addr.ipv4;
zebra_register_rnh_static_nh(&nh_p, rn);
break;
case STATIC_IPV4_IFNAME:
rib_nexthop_ifname_add (rib, si->ifname);
case STATIC_IFINDEX:
rib_nexthop_ifindex_add (rib, si->ifindex);
break;
case STATIC_IPV4_BLACKHOLE:
rib_nexthop_blackhole_add (rib);
@ -2615,11 +2559,8 @@ static_install_route (afi_t afi, safi_t safi, struct prefix *p, struct static_ro
nh_p.u.prefix6 = si->addr.ipv6;
zebra_register_rnh_static_nh(&nh_p, rn);
break;
case STATIC_IPV6_IFNAME:
rib_nexthop_ifname_add (rib, si->ifname);
break;
case STATIC_IPV6_GATEWAY_IFNAME:
rib_nexthop_ipv6_ifname_add (rib, &si->addr.ipv6, si->ifname);
case STATIC_IPV6_GATEWAY_IFINDEX:
rib_nexthop_ipv6_ifindex_add (rib, &si->addr.ipv6, si->ifindex);
break;
}
@ -2663,8 +2604,8 @@ static_install_route (afi_t afi, safi_t safi, struct prefix *p, struct static_ro
nh_p.u.prefix4 = si->addr.ipv4;
zebra_register_rnh_static_nh(&nh_p, rn);
break;
case STATIC_IPV4_IFNAME:
rib_nexthop_ifname_add (rib, si->ifname);
case STATIC_IFINDEX:
rib_nexthop_ifindex_add (rib, si->ifindex);
break;
case STATIC_IPV4_BLACKHOLE:
rib_nexthop_blackhole_add (rib);
@ -2676,11 +2617,8 @@ static_install_route (afi_t afi, safi_t safi, struct prefix *p, struct static_ro
nh_p.u.prefix6 = si->addr.ipv6;
zebra_register_rnh_static_nh(&nh_p, rn);
break;
case STATIC_IPV6_IFNAME:
rib_nexthop_ifname_add (rib, si->ifname);
break;
case STATIC_IPV6_GATEWAY_IFNAME:
rib_nexthop_ipv6_ifname_add (rib, &si->addr.ipv6, si->ifname);
case STATIC_IPV6_GATEWAY_IFINDEX:
rib_nexthop_ipv6_ifindex_add (rib, &si->addr.ipv6, si->ifindex);
break;
}
@ -2718,9 +2656,9 @@ static_nexthop_same (struct nexthop *nexthop, struct static_route *si)
&& si->type == STATIC_IPV4_GATEWAY
&& IPV4_ADDR_SAME (&nexthop->gate.ipv4, &si->addr.ipv4))
return 1;
if (nexthop->type == NEXTHOP_TYPE_IFNAME
&& si->type == STATIC_IPV4_IFNAME
&& strcmp (nexthop->ifname, si->ifname) == 0)
if (nexthop->type == NEXTHOP_TYPE_IFINDEX
&& si->type == STATIC_IFINDEX
&& nexthop->ifindex == si->ifindex)
return 1;
if (nexthop->type == NEXTHOP_TYPE_BLACKHOLE
&& si->type == STATIC_IPV4_BLACKHOLE)
@ -2729,14 +2667,10 @@ static_nexthop_same (struct nexthop *nexthop, struct static_route *si)
&& si->type == STATIC_IPV6_GATEWAY
&& IPV6_ADDR_SAME (&nexthop->gate.ipv6, &si->addr.ipv6))
return 1;
if (nexthop->type == NEXTHOP_TYPE_IFNAME
&& si->type == STATIC_IPV6_IFNAME
&& strcmp (nexthop->ifname, si->ifname) == 0)
return 1;
if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME
&& si->type == STATIC_IPV6_GATEWAY_IFNAME
if (nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX
&& si->type == STATIC_IPV6_GATEWAY_IFINDEX
&& IPV6_ADDR_SAME (&nexthop->gate.ipv6, &si->addr.ipv6)
&& strcmp (nexthop->ifname, si->ifname) == 0)
&& nexthop->ifindex == si->ifindex)
return 1;
return 0;
}
@ -2847,7 +2781,7 @@ static_uninstall_route (afi_t afi, safi_t safi, struct prefix *p, struct static_
/* Add static route into static route configuration. */
int
static_add_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname,
static_add_ipv4 (struct prefix *p, struct in_addr *gate, unsigned int ifindex,
u_char flags, u_short tag, u_char distance, vrf_id_t vrf_id)
{
u_char type = 0;
@ -2868,8 +2802,8 @@ static_add_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname,
/* Make flags. */
if (gate)
type = STATIC_IPV4_GATEWAY;
else if (ifname)
type = STATIC_IPV4_IFNAME;
else if (ifindex)
type = STATIC_IFINDEX;
else
type = STATIC_IPV4_BLACKHOLE;
@ -2878,7 +2812,7 @@ static_add_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname,
{
if (type == si->type
&& (! gate || IPV4_ADDR_SAME (gate, &si->addr.ipv4))
&& (! ifname || strcmp (ifname, si->ifname) == 0))
&& (! ifindex || ifindex == si->ifindex))
{
if ((distance == si->distance) && (tag == si->tag))
{
@ -2892,7 +2826,7 @@ static_add_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname,
/* Distance or tag changed. */
if (update)
static_delete_ipv4 (p, gate, ifname, update->tag, update->distance, vrf_id);
static_delete_ipv4 (p, gate, ifindex, update->tag, update->distance, vrf_id);
/* Make new static route structure. */
si = XCALLOC (MTYPE_STATIC_ROUTE, sizeof (struct static_route));
@ -2902,11 +2836,10 @@ static_add_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname,
si->flags = flags;
si->tag = tag;
si->vrf_id = vrf_id;
si->ifindex = ifindex;
if (gate)
si->addr.ipv4 = *gate;
if (ifname)
si->ifname = XSTRDUP (0, ifname);
/* Add new static route information to the tree with sort by
distance value and gateway address. */
@ -2943,7 +2876,7 @@ static_add_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname,
/* Delete static route from static route configuration. */
int
static_delete_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname,
static_delete_ipv4 (struct prefix *p, struct in_addr *gate, unsigned int ifindex,
u_short tag, u_char distance, vrf_id_t vrf_id)
{
u_char type = 0;
@ -2964,8 +2897,8 @@ static_delete_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname,
/* Make flags. */
if (gate)
type = STATIC_IPV4_GATEWAY;
else if (ifname)
type = STATIC_IPV4_IFNAME;
else if (ifindex)
type = STATIC_IFINDEX;
else
type = STATIC_IPV4_BLACKHOLE;
@ -2973,7 +2906,7 @@ static_delete_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname,
for (si = rn->info; si; si = si->next)
if (type == si->type
&& (! gate || IPV4_ADDR_SAME (gate, &si->addr.ipv4))
&& (! ifname || strcmp (ifname, si->ifname) == 0)
&& (! ifindex || ifindex == si->ifindex)
&& (! tag || (tag == si->tag)))
break;
@ -2997,8 +2930,6 @@ static_delete_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname,
route_unlock_node (rn);
/* Free static route configuration. */
if (ifname)
XFREE (0, si->ifname);
XFREE (MTYPE_STATIC_ROUTE, si);
route_unlock_node (rn);
@ -3395,7 +3326,7 @@ rib_delete_ipv6 (int type, u_short instance, int flags, struct prefix_ipv6 *p,
/* Add static route into static route configuration. */
int
static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
const char *ifname, u_char flags, u_short tag,
unsigned int ifindex, u_char flags, u_short tag,
u_char distance, vrf_id_t vrf_id)
{
struct route_node *rn;
@ -3410,11 +3341,11 @@ static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
return -1;
if (!gate &&
(type == STATIC_IPV6_GATEWAY || type == STATIC_IPV6_GATEWAY_IFNAME))
(type == STATIC_IPV6_GATEWAY || type == STATIC_IPV6_GATEWAY_IFINDEX))
return -1;
if (!ifname &&
(type == STATIC_IPV6_GATEWAY_IFNAME || type == STATIC_IPV6_IFNAME))
if (!ifindex &&
(type == STATIC_IPV6_GATEWAY_IFINDEX || type == STATIC_IFINDEX))
return -1;
/* Lookup static route prefix. */
@ -3425,7 +3356,7 @@ static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
{
if (type == si->type
&& (! gate || IPV6_ADDR_SAME (gate, &si->addr.ipv6))
&& (! ifname || strcmp (ifname, si->ifname) == 0))
&& (! ifindex || ifindex == si->ifindex))
{
if ((distance == si->distance) && (tag == si->tag))
{
@ -3439,7 +3370,7 @@ static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
/* Distance or tag changed. */
if (update)
static_delete_ipv6 (p, type, gate, ifname, update->tag, update->distance, vrf_id);
static_delete_ipv6 (p, type, gate, ifindex, update->tag, update->distance, vrf_id);
/* Make new static route structure. */
si = XCALLOC (MTYPE_STATIC_ROUTE, sizeof (struct static_route));
@ -3449,18 +3380,15 @@ static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
si->flags = flags;
si->tag = tag;
si->vrf_id = vrf_id;
si->ifindex = ifindex;
switch (type)
{
case STATIC_IPV6_GATEWAY:
si->addr.ipv6 = *gate;
break;
case STATIC_IPV6_IFNAME:
si->ifname = XSTRDUP (0, ifname);
break;
case STATIC_IPV6_GATEWAY_IFNAME:
case STATIC_IPV6_GATEWAY_IFINDEX:
si->addr.ipv6 = *gate;
si->ifname = XSTRDUP (0, ifname);
break;
}
@ -3493,7 +3421,7 @@ static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
/* Delete static route from static route configuration. */
int
static_delete_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
const char *ifname, u_short tag, u_char distance,
unsigned int ifindex, u_short tag, u_char distance,
vrf_id_t vrf_id)
{
struct route_node *rn;
@ -3515,7 +3443,7 @@ static_delete_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
if (distance == si->distance
&& type == si->type
&& (! gate || IPV6_ADDR_SAME (gate, &si->addr.ipv6))
&& (! ifname || strcmp (ifname, si->ifname) == 0)
&& (! ifindex || ifindex == si->ifindex)
&& (! tag || (tag == si->tag)))
break;
@ -3538,8 +3466,6 @@ static_delete_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
si->next->prev = si->prev;
/* Free static route configuration. */
if (ifname)
XFREE (0, si->ifname);
XFREE (MTYPE_STATIC_ROUTE, si);
return 1;

View File

@ -1210,11 +1210,9 @@ route_match_ip_next_hop (void *rule, struct prefix *prefix,
switch (nh_data->nexthop->type) {
case NEXTHOP_TYPE_IFINDEX:
case NEXTHOP_TYPE_IFNAME:
/* Interface routes can't match ip next-hop */
return RMAP_NOMATCH;
case NEXTHOP_TYPE_IPV4_IFINDEX:
case NEXTHOP_TYPE_IPV4_IFNAME:
case NEXTHOP_TYPE_IPV4:
p.family = AF_INET;
p.prefix = nh_data->nexthop->gate.ipv4;
@ -1275,11 +1273,9 @@ route_match_ip_next_hop_prefix_list (void *rule, struct prefix *prefix,
switch (nh_data->nexthop->type) {
case NEXTHOP_TYPE_IFINDEX:
case NEXTHOP_TYPE_IFNAME:
/* Interface routes can't match ip next-hop */
return RMAP_NOMATCH;
case NEXTHOP_TYPE_IPV4_IFINDEX:
case NEXTHOP_TYPE_IPV4_IFNAME:
case NEXTHOP_TYPE_IPV4:
p.family = AF_INET;
p.prefix = nh_data->nexthop->gate.ipv4;
@ -1478,11 +1474,9 @@ route_match_ip_nexthop_prefix_len (void *rule, struct prefix *prefix,
switch (nh_data->nexthop->type) {
case NEXTHOP_TYPE_IFINDEX:
case NEXTHOP_TYPE_IFNAME:
/* Interface routes can't match ip next-hop */
return RMAP_NOMATCH;
case NEXTHOP_TYPE_IPV4_IFINDEX:
case NEXTHOP_TYPE_IPV4_IFNAME:
case NEXTHOP_TYPE_IPV4:
p.family = AF_INET;
p.prefix = nh_data->nexthop->gate.ipv4;

View File

@ -493,8 +493,7 @@ ipFwTable (struct variable *v, oid objid[], size_t *objid_len,
return (u_char *)&nexthop->ifindex;
break;
case IPFORWARDTYPE:
if (nexthop->type == NEXTHOP_TYPE_IFINDEX
|| nexthop->type == NEXTHOP_TYPE_IFNAME)
if (nexthop->type == NEXTHOP_TYPE_IFINDEX)
result = 3;
else
result = 4;

View File

@ -49,11 +49,11 @@ zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str,
struct prefix p;
struct in_addr gate;
struct in_addr mask;
const char *ifname;
u_char flag = 0;
u_short tag = 0;
vrf_id_t vrf_id = VRF_DEFAULT;
unsigned int ifindex = 0;
ret = str2prefix (dest_str, &p);
if (ret <= 0)
{
@ -99,9 +99,9 @@ zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str,
return CMD_WARNING;
}
if (add_cmd)
static_add_ipv4 (&p, NULL, NULL, ZEBRA_FLAG_BLACKHOLE, tag, distance, vrf_id);
static_add_ipv4 (&p, NULL, ifindex, ZEBRA_FLAG_BLACKHOLE, tag, distance, vrf_id);
else
static_delete_ipv4 (&p, NULL, NULL, tag, distance, vrf_id);
static_delete_ipv4 (&p, NULL, ifindex, tag, distance, vrf_id);
return CMD_SUCCESS;
}
@ -125,9 +125,9 @@ zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str,
if (gate_str == NULL)
{
if (add_cmd)
static_add_ipv4 (&p, NULL, NULL, flag, tag, distance, vrf_id);
static_add_ipv4 (&p, NULL, ifindex, flag, tag, distance, vrf_id);
else
static_delete_ipv4 (&p, NULL, NULL, tag, distance, vrf_id);
static_delete_ipv4 (&p, NULL, ifindex, tag, distance, vrf_id);
return CMD_SUCCESS;
}
@ -135,15 +135,21 @@ zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str,
/* When gateway is A.B.C.D format, gate is treated as nexthop
address other case gate is treated as interface name. */
ret = inet_aton (gate_str, &gate);
if (ret)
ifname = NULL;
else
ifname = gate_str;
if (!ret)
{
struct interface *ifp = if_lookup_by_name_vrf (gate_str, vrf_id);
if (!ifp)
{
vty_out (vty, "%% Unknown interface: %s%s", gate_str, VTY_NEWLINE);
return CMD_WARNING;
}
ifindex = ifp->ifindex;
}
if (add_cmd)
static_add_ipv4 (&p, ifname ? NULL : &gate, ifname, flag, tag, distance, vrf_id);
static_add_ipv4 (&p, ifindex ? NULL : &gate, ifindex, flag, tag, distance, vrf_id);
else
static_delete_ipv4 (&p, ifname ? NULL : &gate, ifname, tag, distance, vrf_id);
static_delete_ipv4 (&p, ifindex ? NULL : &gate, ifindex, tag, distance, vrf_id);
return CMD_SUCCESS;
}
@ -1818,12 +1824,9 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn)
#ifdef HAVE_IPV6
case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX:
case NEXTHOP_TYPE_IPV6_IFNAME:
vty_out (vty, " %s",
inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
vty_out (vty, ", %s", nexthop->ifname);
else if (nexthop->ifindex)
if (nexthop->ifindex)
vty_out (vty, ", via %s",
ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
break;
@ -1832,9 +1835,6 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn)
vty_out (vty, " directly connected, %s",
ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
break;
case NEXTHOP_TYPE_IFNAME:
vty_out (vty, " directly connected, %s", nexthop->ifname);
break;
case NEXTHOP_TYPE_BLACKHOLE:
vty_out (vty, " directly connected, Null0");
break;
@ -1854,7 +1854,6 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn)
{
case NEXTHOP_TYPE_IPV4:
case NEXTHOP_TYPE_IPV4_IFINDEX:
case NEXTHOP_TYPE_IPV4_IFNAME:
if (nexthop->src.ipv4.s_addr)
{
if (inet_ntop(AF_INET, &nexthop->src.ipv4, addrstr,
@ -1862,10 +1861,8 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn)
vty_out (vty, ", src %s", addrstr);
}
break;
#ifdef HAVE_IPV6
case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX:
case NEXTHOP_TYPE_IPV6_IFNAME:
if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
{
if (inet_ntop(AF_INET6, &nexthop->src.ipv6, addrstr,
@ -1873,7 +1870,6 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn)
vty_out (vty, ", src %s", addrstr);
}
break;
#endif /* HAVE_IPV6 */
default:
break;
}
@ -1935,12 +1931,9 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
#ifdef HAVE_IPV6
case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX:
case NEXTHOP_TYPE_IPV6_IFNAME:
vty_out (vty, " via %s",
inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
vty_out (vty, ", %s", nexthop->ifname);
else if (nexthop->ifindex)
if (nexthop->ifindex)
vty_out (vty, ", %s",
ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
break;
@ -1950,9 +1943,6 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
vty_out (vty, " is directly connected, %s",
ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
break;
case NEXTHOP_TYPE_IFNAME:
vty_out (vty, " is directly connected, %s", nexthop->ifname);
break;
case NEXTHOP_TYPE_BLACKHOLE:
vty_out (vty, " is directly connected, Null0");
break;
@ -1972,7 +1962,6 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
{
case NEXTHOP_TYPE_IPV4:
case NEXTHOP_TYPE_IPV4_IFINDEX:
case NEXTHOP_TYPE_IPV4_IFNAME:
if (nexthop->src.ipv4.s_addr)
{
if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
@ -1982,7 +1971,6 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
#ifdef HAVE_IPV6
case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX:
case NEXTHOP_TYPE_IPV6_IFNAME:
if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
{
if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
@ -3043,8 +3031,8 @@ static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
case STATIC_IPV4_GATEWAY:
vty_out (vty, " %s", inet_ntoa (si->addr.ipv4));
break;
case STATIC_IPV4_IFNAME:
vty_out (vty, " %s", si->ifname);
case STATIC_IFINDEX:
vty_out (vty, " %s", ifindex2ifname_vrf(si->ifindex, si->vrf_id));
break;
case STATIC_IPV4_BLACKHOLE:
vty_out (vty, " Null0");
@ -3178,6 +3166,8 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
vrf_id_t vrf_id = VRF_DEFAULT;
u_char flag = 0;
u_short tag = 0;
unsigned int ifindex = 0;
struct interface *ifp = NULL;
ret = str2prefix (dest_str, &p);
if (ret <= 0)
@ -3229,8 +3219,15 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
return CMD_WARNING;
}
type = STATIC_IPV6_GATEWAY_IFNAME;
type = STATIC_IPV6_GATEWAY_IFINDEX;
gate = &gate_addr;
ifp = if_lookup_by_name_vrf (ifname, vrf_id);
if (!ifp)
{
vty_out (vty, "%% Malformed Interface name %s%s", ifname, VTY_NEWLINE);
return CMD_WARNING;
}
ifindex = ifp->ifindex;
}
else
{
@ -3241,8 +3238,14 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
}
else
{
type = STATIC_IPV6_IFNAME;
ifname = gate_str;
type = STATIC_IFINDEX;
ifp = if_lookup_by_name_vrf (gate_str, vrf_id);
if (!ifp)
{
vty_out (vty, "%% Malformed Interface name %s%s", gate_str, VTY_NEWLINE);
return CMD_WARNING;
}
ifindex = ifp->ifindex;
}
}
@ -3251,9 +3254,9 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
VTY_GET_INTEGER ("VRF ID", vrf_id, vrf_id_str);
if (add_cmd)
static_add_ipv6 (&p, type, gate, ifname, flag, tag, distance, vrf_id);
static_add_ipv6 (&p, type, gate, ifindex, flag, tag, distance, vrf_id);
else
static_delete_ipv6 (&p, type, gate, ifname, tag, distance, vrf_id);
static_delete_ipv6 (&p, type, gate, ifindex, tag, distance, vrf_id);
return CMD_SUCCESS;
}
@ -4321,22 +4324,15 @@ vty_show_ipv6_route_detail (struct vty *vty, struct route_node *rn)
{
case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX:
case NEXTHOP_TYPE_IPV6_IFNAME:
vty_out (vty, " %s",
inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
vty_out (vty, ", %s", nexthop->ifname);
else if (nexthop->ifindex)
if (nexthop->ifindex)
vty_out (vty, ", via %s", ifindex2ifname (nexthop->ifindex));
break;
case NEXTHOP_TYPE_IFINDEX:
vty_out (vty, " directly connected, %s",
ifindex2ifname (nexthop->ifindex));
break;
case NEXTHOP_TYPE_IFNAME:
vty_out (vty, " directly connected, %s",
nexthop->ifname);
break;
default:
break;
}
@ -4395,22 +4391,15 @@ vty_show_ipv6_route (struct vty *vty, struct route_node *rn,
{
case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX:
case NEXTHOP_TYPE_IPV6_IFNAME:
vty_out (vty, " via %s",
inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
vty_out (vty, ", %s", nexthop->ifname);
else if (nexthop->ifindex)
if (nexthop->ifindex)
vty_out (vty, ", %s", ifindex2ifname (nexthop->ifindex));
break;
case NEXTHOP_TYPE_IFINDEX:
vty_out (vty, " is directly connected, %s",
ifindex2ifname (nexthop->ifindex));
break;
case NEXTHOP_TYPE_IFNAME:
vty_out (vty, " is directly connected, %s",
nexthop->ifname);
break;
default:
break;
}
@ -5189,12 +5178,13 @@ static_config_ipv6 (struct vty *vty)
case STATIC_IPV6_GATEWAY:
vty_out (vty, " %s", inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ));
break;
case STATIC_IPV6_IFNAME:
vty_out (vty, " %s", si->ifname);
case STATIC_IFINDEX:
vty_out (vty, " %s", ifindex2ifname_vrf (si->ifindex, si->vrf_id));
break;
case STATIC_IPV6_GATEWAY_IFNAME:
case STATIC_IPV6_GATEWAY_IFINDEX:
vty_out (vty, " %s %s",
inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ), si->ifname);
inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ),
ifindex2ifname_vrf (si->ifindex, si->vrf_id));
break;
}

View File

@ -580,17 +580,14 @@ zsend_redistribute_route (int cmd, struct zserv *client, struct prefix *p,
case NEXTHOP_TYPE_IPV4_IFINDEX:
stream_put_in_addr (s, &nexthop->gate.ipv4);
break;
#ifdef HAVE_IPV6
case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX:
case NEXTHOP_TYPE_IPV6_IFNAME:
/* Only BGP supports IPv4 prefix with IPv6 NH, so kill this */
if (p->family == AF_INET)
stream_put_in_addr(s, &dummy_nh.gate.ipv4);
else
stream_write (s, (u_char *) &nexthop->gate.ipv6, 16);
break;
#endif
default:
if (cmd == ZEBRA_REDISTRIBUTE_IPV4_ADD
|| cmd == ZEBRA_REDISTRIBUTE_IPV4_DEL)
@ -685,12 +682,10 @@ zsend_ipv6_nexthop_lookup (struct zserv *client, struct in6_addr *addr,
stream_put (s, &nexthop->gate.ipv6, 16);
break;
case ZEBRA_NEXTHOP_IPV6_IFINDEX:
case ZEBRA_NEXTHOP_IPV6_IFNAME:
stream_put (s, &nexthop->gate.ipv6, 16);
stream_putl (s, nexthop->ifindex);
break;
case ZEBRA_NEXTHOP_IFINDEX:
case ZEBRA_NEXTHOP_IFNAME:
stream_putl (s, nexthop->ifindex);
break;
default:
@ -759,7 +754,6 @@ zsend_ipv4_nexthop_lookup (struct zserv *client, struct in_addr addr,
stream_putl (s, nexthop->ifindex);
break;
case ZEBRA_NEXTHOP_IFINDEX:
case ZEBRA_NEXTHOP_IFNAME:
stream_putl (s, nexthop->ifindex);
break;
default:
@ -938,7 +932,6 @@ zsend_ipv4_import_lookup (struct zserv *client, struct prefix_ipv4 *p,
stream_putl (s, nexthop->ifindex);
break;
case ZEBRA_NEXTHOP_IFINDEX:
case ZEBRA_NEXTHOP_IFNAME:
stream_putl (s, nexthop->ifindex);
break;
default:
@ -1068,7 +1061,6 @@ zread_ipv4_add (struct zserv *client, u_short length, vrf_id_t vrf_id)
u_char nexthop_type;
struct stream *s;
unsigned int ifindex;
u_char ifname_len;
safi_t safi;
int ret;
@ -1111,10 +1103,6 @@ zread_ipv4_add (struct zserv *client, u_short length, vrf_id_t vrf_id)
ifindex = stream_getl (s);
rib_nexthop_ifindex_add (rib, ifindex);
break;
case ZEBRA_NEXTHOP_IFNAME:
ifname_len = stream_getc (s);
stream_forward_getp (s, ifname_len);
break;
case ZEBRA_NEXTHOP_IPV4:
nexthop.s_addr = stream_get_ipv4 (s);
rib_nexthop_ipv4_add (rib, &nexthop, NULL);
@ -1172,7 +1160,6 @@ zread_ipv4_delete (struct zserv *client, u_short length, vrf_id_t vrf_id)
struct prefix_ipv4 p;
u_char nexthop_num;
u_char nexthop_type;
u_char ifname_len;
s = client->ibuf;
ifindex = 0;
@ -1206,10 +1193,6 @@ zread_ipv4_delete (struct zserv *client, u_short length, vrf_id_t vrf_id)
case ZEBRA_NEXTHOP_IFINDEX:
ifindex = stream_getl (s);
break;
case ZEBRA_NEXTHOP_IFNAME:
ifname_len = stream_getc (s);
stream_forward_getp (s, ifname_len);
break;
case ZEBRA_NEXTHOP_IPV4:
nexthop.s_addr = stream_get_ipv4 (s);
nexthop_p = &nexthop;