mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-09 09:47:11 +00:00
Merge branch 'cmaster' of ssh://stash.cumulusnetworks.com:7999/quag/quagga into cmaster
This commit is contained in:
commit
3d63d59fd1
@ -1,7 +1,7 @@
|
|||||||
## Process this file with automake to produce Makefile.in.
|
## Process this file with automake to produce Makefile.in.
|
||||||
|
|
||||||
INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib
|
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
|
INSTALL_SDATA=@INSTALL@ -m 600
|
||||||
|
|
||||||
AM_CFLAGS = $(PICFLAGS) $(WERROR)
|
AM_CFLAGS = $(PICFLAGS) $(WERROR)
|
||||||
|
@ -83,11 +83,11 @@ bgp_maximum_paths_unset (struct bgp *bgp, afi_t afi, safi_t safi,
|
|||||||
switch (peertype)
|
switch (peertype)
|
||||||
{
|
{
|
||||||
case BGP_PEER_IBGP:
|
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;
|
bgp->maxpaths[afi][safi].ibgp_flags = 0;
|
||||||
break;
|
break;
|
||||||
case BGP_PEER_EBGP:
|
case BGP_PEER_EBGP:
|
||||||
bgp->maxpaths[afi][safi].maxpaths_ebgp = BGP_DEFAULT_MAXPATHS;
|
bgp->maxpaths[afi][safi].maxpaths_ebgp = MULTIPATH_NUM;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -1;
|
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];
|
char path_buf[PATH_ADDPATH_STR_BUFFER];
|
||||||
|
|
||||||
mpath_changed = 0;
|
mpath_changed = 0;
|
||||||
maxpaths = BGP_DEFAULT_MAXPATHS;
|
maxpaths = MULTIPATH_NUM;
|
||||||
mpath_count = 0;
|
mpath_count = 0;
|
||||||
cur_mpath = NULL;
|
cur_mpath = NULL;
|
||||||
old_mpath_count = 0;
|
old_mpath_count = 0;
|
||||||
|
@ -24,12 +24,6 @@
|
|||||||
#ifndef _QUAGGA_BGP_MPATH_H
|
#ifndef _QUAGGA_BGP_MPATH_H
|
||||||
#define _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
|
/* Supplemental information linked to bgp_info for keeping track of
|
||||||
* multipath selections, lazily allocated to save memory
|
* multipath selections, lazily allocated to save memory
|
||||||
*/
|
*/
|
||||||
|
@ -992,7 +992,7 @@ bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths,
|
|||||||
if (set)
|
if (set)
|
||||||
{
|
{
|
||||||
VTY_GET_INTEGER_RANGE ("maximum-paths", maxpaths, mpaths, 1,
|
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,
|
ret = bgp_maximum_paths_set (bgp, afi, safi, peer_type, maxpaths,
|
||||||
options);
|
options);
|
||||||
}
|
}
|
||||||
@ -1011,11 +1011,6 @@ bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths,
|
|||||||
|
|
||||||
bgp_recalculate_all_bestpaths (bgp);
|
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;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1385,7 +1380,7 @@ DEFUN (no_bgp_coalesce_time,
|
|||||||
/* Maximum-paths configuration */
|
/* Maximum-paths configuration */
|
||||||
DEFUN (bgp_maxpaths,
|
DEFUN (bgp_maxpaths,
|
||||||
bgp_maxpaths_cmd,
|
bgp_maxpaths_cmd,
|
||||||
"maximum-paths <1-255>",
|
"maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM),
|
||||||
"Forward packets over multiple paths\n"
|
"Forward packets over multiple paths\n"
|
||||||
"Number of paths\n")
|
"Number of paths\n")
|
||||||
{
|
{
|
||||||
@ -1394,7 +1389,7 @@ DEFUN (bgp_maxpaths,
|
|||||||
|
|
||||||
DEFUN (bgp_maxpaths_ibgp,
|
DEFUN (bgp_maxpaths_ibgp,
|
||||||
bgp_maxpaths_ibgp_cmd,
|
bgp_maxpaths_ibgp_cmd,
|
||||||
"maximum-paths ibgp <1-255>",
|
"maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM),
|
||||||
"Forward packets over multiple paths\n"
|
"Forward packets over multiple paths\n"
|
||||||
"iBGP-multipath\n"
|
"iBGP-multipath\n"
|
||||||
"Number of paths\n")
|
"Number of paths\n")
|
||||||
@ -1404,7 +1399,7 @@ DEFUN (bgp_maxpaths_ibgp,
|
|||||||
|
|
||||||
DEFUN (bgp_maxpaths_ibgp_cluster,
|
DEFUN (bgp_maxpaths_ibgp_cluster,
|
||||||
bgp_maxpaths_ibgp_cluster_cmd,
|
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"
|
"Forward packets over multiple paths\n"
|
||||||
"iBGP-multipath\n"
|
"iBGP-multipath\n"
|
||||||
"Number of paths\n"
|
"Number of paths\n"
|
||||||
@ -1426,7 +1421,7 @@ DEFUN (no_bgp_maxpaths,
|
|||||||
|
|
||||||
ALIAS (no_bgp_maxpaths,
|
ALIAS (no_bgp_maxpaths,
|
||||||
no_bgp_maxpaths_arg_cmd,
|
no_bgp_maxpaths_arg_cmd,
|
||||||
"no maximum-paths <1-255>",
|
"no maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM),
|
||||||
NO_STR
|
NO_STR
|
||||||
"Forward packets over multiple paths\n"
|
"Forward packets over multiple paths\n"
|
||||||
"Number of paths\n")
|
"Number of paths\n")
|
||||||
@ -1444,7 +1439,7 @@ DEFUN (no_bgp_maxpaths_ibgp,
|
|||||||
|
|
||||||
ALIAS (no_bgp_maxpaths_ibgp,
|
ALIAS (no_bgp_maxpaths_ibgp,
|
||||||
no_bgp_maxpaths_ibgp_arg_cmd,
|
no_bgp_maxpaths_ibgp_arg_cmd,
|
||||||
"no maximum-paths ibgp <1-255>",
|
"no maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM),
|
||||||
NO_STR
|
NO_STR
|
||||||
"Forward packets over multiple paths\n"
|
"Forward packets over multiple paths\n"
|
||||||
"iBGP-multipath\n"
|
"iBGP-multipath\n"
|
||||||
@ -1452,7 +1447,7 @@ ALIAS (no_bgp_maxpaths_ibgp,
|
|||||||
|
|
||||||
ALIAS (no_bgp_maxpaths_ibgp,
|
ALIAS (no_bgp_maxpaths_ibgp,
|
||||||
no_bgp_maxpaths_ibgp_cluster_cmd,
|
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
|
NO_STR
|
||||||
"Forward packets over multiple paths\n"
|
"Forward packets over multiple paths\n"
|
||||||
"iBGP-multipath\n"
|
"iBGP-multipath\n"
|
||||||
@ -1463,14 +1458,14 @@ int
|
|||||||
bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi,
|
bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||||
safi_t safi, int *write)
|
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);
|
bgp_config_write_family_header (vty, afi, safi, write);
|
||||||
vty_out (vty, " maximum-paths %d%s",
|
vty_out (vty, " maximum-paths %d%s",
|
||||||
bgp->maxpaths[afi][safi].maxpaths_ebgp, VTY_NEWLINE);
|
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);
|
bgp_config_write_family_header (vty, afi, safi, write);
|
||||||
vty_out (vty, " maximum-paths ibgp %d",
|
vty_out (vty, " maximum-paths ibgp %d",
|
||||||
@ -4320,7 +4315,7 @@ DEFUN (neighbor_ebgp_multihop,
|
|||||||
|
|
||||||
DEFUN (neighbor_ebgp_multihop_ttl,
|
DEFUN (neighbor_ebgp_multihop_ttl,
|
||||||
neighbor_ebgp_multihop_ttl_cmd,
|
neighbor_ebgp_multihop_ttl_cmd,
|
||||||
NEIGHBOR_CMD2 "ebgp-multihop <1-255>",
|
NEIGHBOR_CMD2 "ebgp-multihop " CMD_RANGE_STR(1, MULTIPATH_NUM),
|
||||||
NEIGHBOR_STR
|
NEIGHBOR_STR
|
||||||
NEIGHBOR_ADDR_STR2
|
NEIGHBOR_ADDR_STR2
|
||||||
"Allow EBGP neighbors not on directly connected networks\n"
|
"Allow EBGP neighbors not on directly connected networks\n"
|
||||||
@ -4342,7 +4337,7 @@ DEFUN (no_neighbor_ebgp_multihop,
|
|||||||
|
|
||||||
ALIAS (no_neighbor_ebgp_multihop,
|
ALIAS (no_neighbor_ebgp_multihop,
|
||||||
no_neighbor_ebgp_multihop_ttl_cmd,
|
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
|
NO_STR
|
||||||
NEIGHBOR_STR
|
NEIGHBOR_STR
|
||||||
NEIGHBOR_ADDR_STR2
|
NEIGHBOR_ADDR_STR2
|
||||||
|
@ -62,22 +62,22 @@ struct stream *bgp_ifindices_buf = NULL;
|
|||||||
1. maintain a linked-list and free it after zapi_*_route call
|
1. maintain a linked-list and free it after zapi_*_route call
|
||||||
2. use an array to avoid number of mallocs.
|
2. use an array to avoid number of mallocs.
|
||||||
Number of supported next-hops are finite, use of arrays should be ok. */
|
Number of supported next-hops are finite, use of arrays should be ok. */
|
||||||
struct attr attr_cp[BGP_MAXIMUM_MAXPATHS];
|
struct attr attr_cp[MULTIPATH_NUM];
|
||||||
struct attr_extra attr_extra_cp[BGP_MAXIMUM_MAXPATHS];
|
struct attr_extra attr_extra_cp[MULTIPATH_NUM];
|
||||||
int attr_index = 0;
|
int attr_index = 0;
|
||||||
|
|
||||||
/* Once per address-family initialization of the attribute array */
|
/* Once per address-family initialization of the attribute array */
|
||||||
#define BGP_INFO_ATTR_BUF_INIT()\
|
#define BGP_INFO_ATTR_BUF_INIT()\
|
||||||
do {\
|
do {\
|
||||||
memset(attr_cp, 0, BGP_MAXIMUM_MAXPATHS * sizeof(struct attr));\
|
memset(attr_cp, 0, MULTIPATH_NUM * sizeof(struct attr));\
|
||||||
memset(attr_extra_cp, 0, BGP_MAXIMUM_MAXPATHS * sizeof(struct attr_extra));\
|
memset(attr_extra_cp, 0, MULTIPATH_NUM * sizeof(struct attr_extra));\
|
||||||
attr_index = 0;\
|
attr_index = 0;\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define BGP_INFO_ATTR_BUF_COPY(info_src, info_dst)\
|
#define BGP_INFO_ATTR_BUF_COPY(info_src, info_dst)\
|
||||||
do { \
|
do { \
|
||||||
*info_dst = *info_src; \
|
*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]; \
|
attr_cp[attr_index].extra = &attr_extra_cp[attr_index]; \
|
||||||
bgp_attr_dup (&attr_cp[attr_index], info_src->attr); \
|
bgp_attr_dup (&attr_cp[attr_index], info_src->attr); \
|
||||||
bgp_attr_deep_dup (&attr_cp[attr_index], info_src->attr); \
|
bgp_attr_deep_dup (&attr_cp[attr_index], info_src->attr); \
|
||||||
|
@ -2728,8 +2728,8 @@ bgp_create (as_t *as, const char *name)
|
|||||||
bgp->rib[afi][safi] = bgp_table_init (afi, safi);
|
bgp->rib[afi][safi] = bgp_table_init (afi, safi);
|
||||||
|
|
||||||
/* Enable maximum-paths */
|
/* 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_EBGP, MULTIPATH_NUM, 0);
|
||||||
bgp_maximum_paths_set (bgp, afi, safi, BGP_PEER_IBGP, BGP_DEFAULT_MAXPATHS, 0);
|
bgp_maximum_paths_set (bgp, afi, safi, BGP_PEER_IBGP, MULTIPATH_NUM, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bgp->v_update_delay = BGP_UPDATE_DELAY_DEF;
|
bgp->v_update_delay = BGP_UPDATE_DELAY_DEF;
|
||||||
|
@ -412,14 +412,14 @@ AC_DEFINE_UNQUOTED(CONFIGFILE_MASK, ${enable_configfile_mask}, Mask for config f
|
|||||||
enable_logfile_mask=${enable_logfile_mask:-0600}
|
enable_logfile_mask=${enable_logfile_mask:-0600}
|
||||||
AC_DEFINE_UNQUOTED(LOGFILE_MASK, ${enable_logfile_mask}, Mask for log files)
|
AC_DEFINE_UNQUOTED(LOGFILE_MASK, ${enable_logfile_mask}, Mask for log files)
|
||||||
|
|
||||||
MULTIPATH_NUM=1
|
MPATH_NUM=1
|
||||||
|
|
||||||
case "${enable_multipath}" in
|
case "${enable_multipath}" in
|
||||||
0)
|
0)
|
||||||
MULTIPATH_NUM=64
|
MPATH_NUM=64
|
||||||
;;
|
;;
|
||||||
[[1-9]|[1-9][0-9]])
|
[[1-9]|[1-9][0-9]])
|
||||||
MULTIPATH_NUM="${enable_multipath}"
|
MPATH_NUM="${enable_multipath}"
|
||||||
;;
|
;;
|
||||||
"")
|
"")
|
||||||
;;
|
;;
|
||||||
@ -428,7 +428,7 @@ case "${enable_multipath}" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
AC_SUBST(MULTIPATH_NUM)
|
AC_DEFINE_UNQUOTED(MULTIPATH_NUM, $MPATH_NUM, Maximum number of paths for a route)
|
||||||
|
|
||||||
dnl -----------------------------------
|
dnl -----------------------------------
|
||||||
dnl Add extra version string to package
|
dnl Add extra version string to package
|
||||||
|
@ -437,6 +437,17 @@ struct cmd_token
|
|||||||
#endif /* VTYSH_EXTRACT_PL */
|
#endif /* VTYSH_EXTRACT_PL */
|
||||||
|
|
||||||
/* Some macroes */
|
/* 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_OPTION(S) ((S[0]) == '[')
|
||||||
#define CMD_VARIABLE(S) (((S[0]) >= 'A' && (S[0]) <= 'Z') || ((S[0]) == '<'))
|
#define CMD_VARIABLE(S) (((S[0]) >= 'A' && (S[0]) <= 'Z') || ((S[0]) == '<'))
|
||||||
#define CMD_VARARG(S) ((S[0]) == '.')
|
#define CMD_VARARG(S) ((S[0]) == '.')
|
||||||
|
@ -50,23 +50,19 @@ nexthop_same_no_recurse (struct nexthop *next1, struct nexthop *next2)
|
|||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
case NEXTHOP_TYPE_IFINDEX:
|
case NEXTHOP_TYPE_IFINDEX:
|
||||||
case NEXTHOP_TYPE_IFNAME:
|
|
||||||
if (next1->ifindex != next2->ifindex)
|
if (next1->ifindex != next2->ifindex)
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
case NEXTHOP_TYPE_IPV6:
|
case NEXTHOP_TYPE_IPV6:
|
||||||
if (! IPV6_ADDR_SAME (&next1->gate.ipv6, &next2->gate.ipv6))
|
if (! IPV6_ADDR_SAME (&next1->gate.ipv6, &next2->gate.ipv6))
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
||||||
case NEXTHOP_TYPE_IPV6_IFNAME:
|
|
||||||
if (! IPV6_ADDR_SAME (&next1->gate.ipv6, &next2->gate.ipv6))
|
if (! IPV6_ADDR_SAME (&next1->gate.ipv6, &next2->gate.ipv6))
|
||||||
return 0;
|
return 0;
|
||||||
if (next1->ifindex != next2->ifindex)
|
if (next1->ifindex != next2->ifindex)
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
#endif /* HAVE_IPV6 */
|
|
||||||
default:
|
default:
|
||||||
/* do nothing */
|
/* do nothing */
|
||||||
break;
|
break;
|
||||||
@ -132,8 +128,6 @@ copy_nexthops (struct nexthop **tnh, struct nexthop *nh)
|
|||||||
nexthop->flags = nh->flags;
|
nexthop->flags = nh->flags;
|
||||||
nexthop->type = nh->type;
|
nexthop->type = nh->type;
|
||||||
nexthop->ifindex = nh->ifindex;
|
nexthop->ifindex = nh->ifindex;
|
||||||
if (nh->ifname)
|
|
||||||
nexthop->ifname = XSTRDUP(0, nh->ifname);
|
|
||||||
memcpy(&(nexthop->gate), &(nh->gate), sizeof(union g_addr));
|
memcpy(&(nexthop->gate), &(nh->gate), sizeof(union g_addr));
|
||||||
memcpy(&(nexthop->src), &(nh->src), sizeof(union g_addr));
|
memcpy(&(nexthop->src), &(nh->src), sizeof(union g_addr));
|
||||||
nexthop_add(tnh, nexthop);
|
nexthop_add(tnh, nexthop);
|
||||||
@ -147,8 +141,6 @@ copy_nexthops (struct nexthop **tnh, struct nexthop *nh)
|
|||||||
void
|
void
|
||||||
nexthop_free (struct nexthop *nexthop)
|
nexthop_free (struct nexthop *nexthop)
|
||||||
{
|
{
|
||||||
if (nexthop->ifname)
|
|
||||||
XFREE (0, nexthop->ifname);
|
|
||||||
if (nexthop->resolved)
|
if (nexthop->resolved)
|
||||||
nexthops_free(nexthop->resolved);
|
nexthops_free(nexthop->resolved);
|
||||||
XFREE (MTYPE_NEXTHOP, nexthop);
|
XFREE (MTYPE_NEXTHOP, nexthop);
|
||||||
|
@ -34,13 +34,10 @@ union g_addr {
|
|||||||
enum nexthop_types_t
|
enum nexthop_types_t
|
||||||
{
|
{
|
||||||
NEXTHOP_TYPE_IFINDEX = 1, /* Directly connected. */
|
NEXTHOP_TYPE_IFINDEX = 1, /* Directly connected. */
|
||||||
NEXTHOP_TYPE_IFNAME, /* Interface route. */
|
|
||||||
NEXTHOP_TYPE_IPV4, /* IPv4 nexthop. */
|
NEXTHOP_TYPE_IPV4, /* IPv4 nexthop. */
|
||||||
NEXTHOP_TYPE_IPV4_IFINDEX, /* IPv4 nexthop with ifindex. */
|
NEXTHOP_TYPE_IPV4_IFINDEX, /* IPv4 nexthop with ifindex. */
|
||||||
NEXTHOP_TYPE_IPV4_IFNAME, /* IPv4 nexthop with ifname. */
|
|
||||||
NEXTHOP_TYPE_IPV6, /* IPv6 nexthop. */
|
NEXTHOP_TYPE_IPV6, /* IPv6 nexthop. */
|
||||||
NEXTHOP_TYPE_IPV6_IFINDEX, /* IPv6 nexthop with ifindex. */
|
NEXTHOP_TYPE_IPV6_IFINDEX, /* IPv6 nexthop with ifindex. */
|
||||||
NEXTHOP_TYPE_IPV6_IFNAME, /* IPv6 nexthop with ifname. */
|
|
||||||
NEXTHOP_TYPE_BLACKHOLE, /* Null0 nexthop. */
|
NEXTHOP_TYPE_BLACKHOLE, /* Null0 nexthop. */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -51,7 +48,6 @@ struct nexthop
|
|||||||
struct nexthop *prev;
|
struct nexthop *prev;
|
||||||
|
|
||||||
/* Interface index. */
|
/* Interface index. */
|
||||||
char *ifname;
|
|
||||||
unsigned int ifindex;
|
unsigned int ifindex;
|
||||||
|
|
||||||
enum nexthop_types_t type;
|
enum nexthop_types_t type;
|
||||||
|
15
lib/zebra.h
15
lib/zebra.h
@ -499,15 +499,12 @@ extern const char *zserv_command_string (unsigned int command);
|
|||||||
|
|
||||||
/* Zebra nexthop flags. */
|
/* Zebra nexthop flags. */
|
||||||
#define ZEBRA_NEXTHOP_IFINDEX 1
|
#define ZEBRA_NEXTHOP_IFINDEX 1
|
||||||
#define ZEBRA_NEXTHOP_IFNAME 2
|
#define ZEBRA_NEXTHOP_IPV4 2
|
||||||
#define ZEBRA_NEXTHOP_IPV4 3
|
#define ZEBRA_NEXTHOP_IPV4_IFINDEX 3
|
||||||
#define ZEBRA_NEXTHOP_IPV4_IFINDEX 4
|
#define ZEBRA_NEXTHOP_IPV6 4
|
||||||
#define ZEBRA_NEXTHOP_IPV4_IFNAME 5
|
#define ZEBRA_NEXTHOP_IPV6_IFINDEX 5
|
||||||
#define ZEBRA_NEXTHOP_IPV6 6
|
#define ZEBRA_NEXTHOP_BLACKHOLE 6
|
||||||
#define ZEBRA_NEXTHOP_IPV6_IFINDEX 7
|
#define ZEBRA_NEXTHOP_IPV4_ONLINK 7
|
||||||
#define ZEBRA_NEXTHOP_IPV6_IFNAME 8
|
|
||||||
#define ZEBRA_NEXTHOP_BLACKHOLE 9
|
|
||||||
#define ZEBRA_NEXTHOP_IPV4_ONLINK 10
|
|
||||||
|
|
||||||
#ifndef INADDR_LOOPBACK
|
#ifndef INADDR_LOOPBACK
|
||||||
#define INADDR_LOOPBACK 0x7f000001 /* Internet address 127.0.0.1. */
|
#define INADDR_LOOPBACK 0x7f000001 /* Internet address 127.0.0.1. */
|
||||||
|
@ -113,8 +113,8 @@ bgp_create_fake (as_t *as, const char *name)
|
|||||||
bgp->route[afi][safi] = bgp_table_init (afi, safi);
|
bgp->route[afi][safi] = bgp_table_init (afi, safi);
|
||||||
bgp->aggregate[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->rib[afi][safi] = bgp_table_init (afi, safi);
|
||||||
bgp->maxpaths[afi][safi].maxpaths_ebgp = BGP_DEFAULT_MAXPATHS;
|
bgp->maxpaths[afi][safi].maxpaths_ebgp = MULTIPATH_NUM;
|
||||||
bgp->maxpaths[afi][safi].maxpaths_ibgp = BGP_DEFAULT_MAXPATHS;
|
bgp->maxpaths[afi][safi].maxpaths_ibgp = MULTIPATH_NUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
bgp->default_local_pref = BGP_DEFAULT_LOCAL_PREF;
|
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);
|
api_result = bgp_maximum_paths_unset (bgp, afi, safi, BGP_PEER_IBGP);
|
||||||
EXPECT_TRUE (api_result == 0, test_result);
|
EXPECT_TRUE (api_result == 0, test_result);
|
||||||
EXPECT_TRUE ((bgp->maxpaths[afi][safi].maxpaths_ebgp ==
|
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 ==
|
EXPECT_TRUE ((bgp->maxpaths[afi][safi].maxpaths_ibgp ==
|
||||||
BGP_DEFAULT_MAXPATHS), test_result);
|
MULTIPATH_NUM), test_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return test_result;
|
return test_result;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
## Process this file with automake to produce Makefile.in.
|
## Process this file with automake to produce Makefile.in.
|
||||||
|
|
||||||
INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib
|
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
|
INSTALL_SDATA=@INSTALL@ -m 600
|
||||||
|
|
||||||
LIB_IPV6 = @LIB_IPV6@
|
LIB_IPV6 = @LIB_IPV6@
|
||||||
|
25
zebra/rib.h
25
zebra/rib.h
@ -186,23 +186,22 @@ struct static_route
|
|||||||
|
|
||||||
/* Flag for this static route's type. */
|
/* Flag for this static route's type. */
|
||||||
u_char type;
|
u_char type;
|
||||||
#define STATIC_IPV4_GATEWAY 1
|
#define STATIC_IFINDEX 1
|
||||||
#define STATIC_IPV4_IFNAME 2
|
#define STATIC_IPV4_GATEWAY 2
|
||||||
#define STATIC_IPV4_BLACKHOLE 3
|
#define STATIC_IPV4_BLACKHOLE 3
|
||||||
#define STATIC_IPV6_GATEWAY 4
|
#define STATIC_IPV6_GATEWAY 4
|
||||||
#define STATIC_IPV6_GATEWAY_IFNAME 5
|
#define STATIC_IPV6_GATEWAY_IFINDEX 5
|
||||||
#define STATIC_IPV6_IFNAME 6
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Nexthop value.
|
* Nexthop value.
|
||||||
*
|
*
|
||||||
* Under IPv4 addr and ifname are
|
* Under IPv4 addr and ifindex are
|
||||||
* used independentyly.
|
* used independentyly.
|
||||||
* STATIC_IPV4_GATEWAY uses addr
|
* STATIC_IPV4_GATEWAY uses addr
|
||||||
* STATIC_IPV4_IFNAME uses ifname
|
* STATIC_IFINDEX uses ifindex
|
||||||
*/
|
*/
|
||||||
union g_addr addr;
|
union g_addr addr;
|
||||||
char *ifname;
|
unsigned int ifindex;
|
||||||
|
|
||||||
/* bit flags */
|
/* bit flags */
|
||||||
u_char flags;
|
u_char flags;
|
||||||
@ -380,7 +379,6 @@ typedef enum
|
|||||||
} rib_update_event_t;
|
} rib_update_event_t;
|
||||||
|
|
||||||
extern struct nexthop *rib_nexthop_ifindex_add (struct rib *, unsigned int);
|
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_blackhole_add (struct rib *);
|
||||||
extern struct nexthop *rib_nexthop_ipv4_add (struct rib *, struct in_addr *,
|
extern struct nexthop *rib_nexthop_ipv4_add (struct rib *, struct in_addr *,
|
||||||
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,
|
extern struct nexthop *rib_nexthop_ipv6_ifindex_add (struct rib *rib,
|
||||||
struct in6_addr *ipv6,
|
struct in6_addr *ipv6,
|
||||||
unsigned int ifindex);
|
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_lookup (vrf_id_t vrf_id);
|
||||||
extern struct zebra_vrf *zebra_vrf_alloc (vrf_id_t);
|
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
|
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);
|
u_char flags, u_short tag, u_char distance, vrf_id_t vrf_id);
|
||||||
|
|
||||||
extern int
|
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);
|
u_short tag, u_char distance, vrf_id_t vrf_id);
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
@ -478,7 +473,7 @@ extern struct route_table *rib_table_ipv6;
|
|||||||
|
|
||||||
extern int
|
extern int
|
||||||
static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
|
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);
|
u_char distance, vrf_id_t vrf_id);
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
@ -487,7 +482,7 @@ rib_add_ipv6_multipath (struct prefix *, struct rib *, safi_t,
|
|||||||
|
|
||||||
extern int
|
extern int
|
||||||
static_delete_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
|
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);
|
vrf_id_t vrf_id);
|
||||||
|
|
||||||
extern int rib_gc_dest (struct route_node *rn);
|
extern int rib_gc_dest (struct route_node *rn);
|
||||||
|
@ -1504,7 +1504,6 @@ _netlink_route_build_singlepath(
|
|||||||
|
|
||||||
if (rtmsg->rtm_family == AF_INET &&
|
if (rtmsg->rtm_family == AF_INET &&
|
||||||
(nexthop->type == NEXTHOP_TYPE_IPV6
|
(nexthop->type == NEXTHOP_TYPE_IPV6
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME
|
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX))
|
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX))
|
||||||
{
|
{
|
||||||
char buf[16] = "169.254.0.1";
|
char buf[16] = "169.254.0.1";
|
||||||
@ -1555,9 +1554,7 @@ _netlink_route_build_singlepath(
|
|||||||
inet_ntoa (nexthop->gate.ipv4),
|
inet_ntoa (nexthop->gate.ipv4),
|
||||||
nexthop->ifindex);
|
nexthop->ifindex);
|
||||||
}
|
}
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
if (nexthop->type == NEXTHOP_TYPE_IPV6
|
if (nexthop->type == NEXTHOP_TYPE_IPV6
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME
|
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
|
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
|
||||||
{
|
{
|
||||||
addattr_l (nlmsg, req_size, RTA_GATEWAY,
|
addattr_l (nlmsg, req_size, RTA_GATEWAY,
|
||||||
@ -1580,9 +1577,7 @@ _netlink_route_build_singlepath(
|
|||||||
inet6_ntoa (nexthop->gate.ipv6),
|
inet6_ntoa (nexthop->gate.ipv6),
|
||||||
nexthop->ifindex);
|
nexthop->ifindex);
|
||||||
}
|
}
|
||||||
#endif /* HAVE_IPV6 */
|
|
||||||
if (nexthop->type == NEXTHOP_TYPE_IFINDEX
|
if (nexthop->type == NEXTHOP_TYPE_IFINDEX
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IFNAME
|
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX)
|
|| nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX)
|
||||||
{
|
{
|
||||||
addattr32 (nlmsg, req_size, RTA_OIF, nexthop->ifindex);
|
addattr32 (nlmsg, req_size, RTA_OIF, nexthop->ifindex);
|
||||||
@ -1602,8 +1597,7 @@ _netlink_route_build_singlepath(
|
|||||||
"nexthop via if %u", routedesc, nexthop->ifindex);
|
"nexthop via if %u", routedesc, nexthop->ifindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX
|
if (nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
|
|
||||||
{
|
{
|
||||||
addattr32 (nlmsg, req_size, RTA_OIF, nexthop->ifindex);
|
addattr32 (nlmsg, req_size, RTA_OIF, nexthop->ifindex);
|
||||||
|
|
||||||
@ -1656,7 +1650,6 @@ _netlink_route_build_multipath(
|
|||||||
|
|
||||||
if (rtmsg->rtm_family == AF_INET &&
|
if (rtmsg->rtm_family == AF_INET &&
|
||||||
(nexthop->type == NEXTHOP_TYPE_IPV6
|
(nexthop->type == NEXTHOP_TYPE_IPV6
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME
|
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX))
|
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX))
|
||||||
{
|
{
|
||||||
char buf[16] = "169.254.0.1";
|
char buf[16] = "169.254.0.1";
|
||||||
@ -1705,9 +1698,7 @@ _netlink_route_build_multipath(
|
|||||||
inet_ntoa (nexthop->gate.ipv4),
|
inet_ntoa (nexthop->gate.ipv4),
|
||||||
nexthop->ifindex);
|
nexthop->ifindex);
|
||||||
}
|
}
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
if (nexthop->type == NEXTHOP_TYPE_IPV6
|
if (nexthop->type == NEXTHOP_TYPE_IPV6
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME
|
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
|
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
|
||||||
{
|
{
|
||||||
rta_addattr_l (rta, NL_PKT_BUF_SIZE, RTA_GATEWAY,
|
rta_addattr_l (rta, NL_PKT_BUF_SIZE, RTA_GATEWAY,
|
||||||
@ -1726,11 +1717,9 @@ _netlink_route_build_multipath(
|
|||||||
inet6_ntoa (nexthop->gate.ipv6),
|
inet6_ntoa (nexthop->gate.ipv6),
|
||||||
nexthop->ifindex);
|
nexthop->ifindex);
|
||||||
}
|
}
|
||||||
#endif /* HAVE_IPV6 */
|
|
||||||
/* ifindex */
|
/* ifindex */
|
||||||
if (nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX
|
if (nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IFINDEX
|
|| nexthop->type == NEXTHOP_TYPE_IFINDEX)
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IFNAME)
|
|
||||||
{
|
{
|
||||||
rtnh->rtnh_ifindex = nexthop->ifindex;
|
rtnh->rtnh_ifindex = nexthop->ifindex;
|
||||||
|
|
||||||
@ -1743,8 +1732,7 @@ _netlink_route_build_multipath(
|
|||||||
zlog_debug("netlink_route_multipath() (%s): "
|
zlog_debug("netlink_route_multipath() (%s): "
|
||||||
"nexthop via if %u", routedesc, nexthop->ifindex);
|
"nexthop via if %u", routedesc, nexthop->ifindex);
|
||||||
}
|
}
|
||||||
else if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME
|
else if (nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
|
|
||||||
{
|
{
|
||||||
rtnh->rtnh_ifindex = nexthop->ifindex;
|
rtnh->rtnh_ifindex = nexthop->ifindex;
|
||||||
|
|
||||||
|
@ -123,7 +123,6 @@ kernel_rtm_ipv4 (int cmd, struct prefix *p, struct rib *rib, int family)
|
|||||||
gate = 1;
|
gate = 1;
|
||||||
}
|
}
|
||||||
if (nexthop->type == NEXTHOP_TYPE_IFINDEX
|
if (nexthop->type == NEXTHOP_TYPE_IFINDEX
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IFNAME
|
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX)
|
|| nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX)
|
||||||
ifindex = nexthop->ifindex;
|
ifindex = nexthop->ifindex;
|
||||||
if (nexthop->type == NEXTHOP_TYPE_BLACKHOLE)
|
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
|
if (nexthop->type == NEXTHOP_TYPE_IPV6
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME
|
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
|
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
|
||||||
{
|
{
|
||||||
sin_gate.sin6_addr = nexthop->gate.ipv6;
|
sin_gate.sin6_addr = nexthop->gate.ipv6;
|
||||||
gate = 1;
|
gate = 1;
|
||||||
}
|
}
|
||||||
if (nexthop->type == NEXTHOP_TYPE_IFINDEX
|
if (nexthop->type == NEXTHOP_TYPE_IFINDEX
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IFNAME
|
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME
|
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
|
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
|
||||||
ifindex = nexthop->ifindex;
|
ifindex = nexthop->ifindex;
|
||||||
|
|
||||||
|
@ -176,17 +176,13 @@ netlink_route_info_add_nh (netlink_route_info_t *ri, struct nexthop *nexthop,
|
|||||||
src = &nexthop->src;
|
src = &nexthop->src;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
if (nexthop->type == NEXTHOP_TYPE_IPV6
|
if (nexthop->type == NEXTHOP_TYPE_IPV6
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME
|
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
|
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
|
||||||
{
|
{
|
||||||
nhi.gateway = &nexthop->gate;
|
nhi.gateway = &nexthop->gate;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_IPV6 */
|
|
||||||
|
|
||||||
if (nexthop->type == NEXTHOP_TYPE_IFINDEX
|
if (nexthop->type == NEXTHOP_TYPE_IFINDEX)
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IFNAME)
|
|
||||||
{
|
{
|
||||||
if (nexthop->src.ipv4.s_addr)
|
if (nexthop->src.ipv4.s_addr)
|
||||||
src = &nexthop->src;
|
src = &nexthop->src;
|
||||||
|
@ -147,8 +147,6 @@ rib_copy_nexthops (struct rib *rib, struct nexthop *nh)
|
|||||||
nexthop->flags = nh->flags;
|
nexthop->flags = nh->flags;
|
||||||
nexthop->type = nh->type;
|
nexthop->type = nh->type;
|
||||||
nexthop->ifindex = nh->ifindex;
|
nexthop->ifindex = nh->ifindex;
|
||||||
if (nh->ifname)
|
|
||||||
nexthop->ifname = XSTRDUP(0, nh->ifname);
|
|
||||||
memcpy(&(nexthop->gate), &(nh->gate), sizeof(union g_addr));
|
memcpy(&(nexthop->gate), &(nh->gate), sizeof(union g_addr));
|
||||||
memcpy(&(nexthop->src), &(nh->src), sizeof(union g_addr));
|
memcpy(&(nexthop->src), &(nh->src), sizeof(union g_addr));
|
||||||
rib_nexthop_add(rib, nexthop);
|
rib_nexthop_add(rib, nexthop);
|
||||||
@ -185,20 +183,6 @@ rib_nexthop_ifindex_add (struct rib *rib, unsigned int ifindex)
|
|||||||
return nexthop;
|
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 *
|
struct nexthop *
|
||||||
rib_nexthop_ipv4_add (struct rib *rib, struct in_addr *ipv4, struct in_addr *src)
|
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;
|
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 *
|
struct nexthop *
|
||||||
rib_nexthop_ipv6_ifindex_add (struct rib *rib, struct in6_addr *ipv6,
|
rib_nexthop_ipv6_ifindex_add (struct rib *rib, struct in6_addr *ipv6,
|
||||||
unsigned int ifindex)
|
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);
|
SET_FLAG (resolved_hop->flags, NEXTHOP_FLAG_ACTIVE);
|
||||||
/* If the resolving route specifies a gateway, use it */
|
/* If the resolving route specifies a gateway, use it */
|
||||||
if (newhop->type == NEXTHOP_TYPE_IPV4
|
if (newhop->type == NEXTHOP_TYPE_IPV4
|
||||||
|| newhop->type == NEXTHOP_TYPE_IPV4_IFINDEX
|
|| newhop->type == NEXTHOP_TYPE_IPV4_IFINDEX)
|
||||||
|| newhop->type == NEXTHOP_TYPE_IPV4_IFNAME)
|
|
||||||
{
|
{
|
||||||
resolved_hop->type = newhop->type;
|
resolved_hop->type = newhop->type;
|
||||||
resolved_hop->gate.ipv4 = newhop->gate.ipv4;
|
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
|
* On Linux, we have to set the onlink netlink flag because
|
||||||
* otherwise, the kernel won't accept the route. */
|
* otherwise, the kernel won't accept the route. */
|
||||||
if (newhop->type == NEXTHOP_TYPE_IFINDEX
|
if (newhop->type == NEXTHOP_TYPE_IFINDEX)
|
||||||
|| newhop->type == NEXTHOP_TYPE_IFNAME)
|
|
||||||
{
|
{
|
||||||
resolved_hop->flags |= NEXTHOP_FLAG_ONLINK;
|
resolved_hop->flags |= NEXTHOP_FLAG_ONLINK;
|
||||||
resolved_hop->type = NEXTHOP_TYPE_IPV4_IFINDEX;
|
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);
|
SET_FLAG (resolved_hop->flags, NEXTHOP_FLAG_ACTIVE);
|
||||||
/* If the resolving route specifies a gateway, use it */
|
/* If the resolving route specifies a gateway, use it */
|
||||||
if (newhop->type == NEXTHOP_TYPE_IPV4
|
if (newhop->type == NEXTHOP_TYPE_IPV4
|
||||||
|| newhop->type == NEXTHOP_TYPE_IPV4_IFINDEX
|
|| newhop->type == NEXTHOP_TYPE_IPV4_IFINDEX)
|
||||||
|| newhop->type == NEXTHOP_TYPE_IPV4_IFNAME)
|
|
||||||
{
|
{
|
||||||
resolved_hop->type = newhop->type;
|
resolved_hop->type = newhop->type;
|
||||||
resolved_hop->gate.ipv4 = newhop->gate.ipv4;
|
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
|
* On Linux, we have to set the onlink netlink flag because
|
||||||
* otherwise, the kernel won't accept the route.
|
* otherwise, the kernel won't accept the route.
|
||||||
*/
|
*/
|
||||||
if (newhop->type == NEXTHOP_TYPE_IFINDEX
|
if (newhop->type == NEXTHOP_TYPE_IFINDEX)
|
||||||
|| newhop->type == NEXTHOP_TYPE_IFNAME)
|
|
||||||
{
|
{
|
||||||
resolved_hop->flags |= NEXTHOP_FLAG_ONLINK;
|
resolved_hop->flags |= NEXTHOP_FLAG_ONLINK;
|
||||||
resolved_hop->type = NEXTHOP_TYPE_IPV4_IFINDEX;
|
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
|
/* See nexthop_active_ipv4 for a description how the
|
||||||
* resolved nexthop is constructed. */
|
* resolved nexthop is constructed. */
|
||||||
if (newhop->type == NEXTHOP_TYPE_IPV6
|
if (newhop->type == NEXTHOP_TYPE_IPV6
|
||||||
|| newhop->type == NEXTHOP_TYPE_IPV6_IFINDEX
|
|| newhop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
|
||||||
|| newhop->type == NEXTHOP_TYPE_IPV6_IFNAME)
|
|
||||||
{
|
{
|
||||||
resolved_hop->type = newhop->type;
|
resolved_hop->type = newhop->type;
|
||||||
resolved_hop->gate.ipv6 = newhop->gate.ipv6;
|
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
|
if (newhop->type == NEXTHOP_TYPE_IFINDEX)
|
||||||
|| newhop->type == NEXTHOP_TYPE_IFNAME)
|
|
||||||
{
|
{
|
||||||
resolved_hop->flags |= NEXTHOP_FLAG_ONLINK;
|
resolved_hop->flags |= NEXTHOP_FLAG_ONLINK;
|
||||||
resolved_hop->type = NEXTHOP_TYPE_IPV6_IFINDEX;
|
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
|
/* See nexthop_active_ipv4 for a description how the
|
||||||
* resolved nexthop is constructed. */
|
* resolved nexthop is constructed. */
|
||||||
if (newhop->type == NEXTHOP_TYPE_IPV6
|
if (newhop->type == NEXTHOP_TYPE_IPV6
|
||||||
|| newhop->type == NEXTHOP_TYPE_IPV6_IFINDEX
|
|| newhop->type == NEXTHOP_TYPE_IPV6_IFINDEX)
|
||||||
|| newhop->type == NEXTHOP_TYPE_IPV6_IFNAME)
|
|
||||||
{
|
{
|
||||||
resolved_hop->type = newhop->type;
|
resolved_hop->type = newhop->type;
|
||||||
resolved_hop->gate.ipv6 = newhop->gate.ipv6;
|
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
|
if (newhop->type == NEXTHOP_TYPE_IFINDEX)
|
||||||
|| newhop->type == NEXTHOP_TYPE_IFNAME)
|
|
||||||
{
|
{
|
||||||
resolved_hop->flags |= NEXTHOP_FLAG_ONLINK;
|
resolved_hop->flags |= NEXTHOP_FLAG_ONLINK;
|
||||||
resolved_hop->type = NEXTHOP_TYPE_IPV6_IFINDEX;
|
resolved_hop->type = NEXTHOP_TYPE_IPV6_IFINDEX;
|
||||||
@ -1020,23 +980,6 @@ nexthop_active_check (struct route_node *rn, struct rib *rib,
|
|||||||
else
|
else
|
||||||
UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE);
|
UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE);
|
||||||
break;
|
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:
|
||||||
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
||||||
family = AFI_IP;
|
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));
|
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",
|
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);
|
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;
|
nh_p.u.prefix4 = si->addr.ipv4;
|
||||||
zebra_register_rnh_static_nh(&nh_p, rn);
|
zebra_register_rnh_static_nh(&nh_p, rn);
|
||||||
break;
|
break;
|
||||||
case STATIC_IPV4_IFNAME:
|
case STATIC_IFINDEX:
|
||||||
rib_nexthop_ifname_add (rib, si->ifname);
|
rib_nexthop_ifindex_add (rib, si->ifindex);
|
||||||
break;
|
break;
|
||||||
case STATIC_IPV4_BLACKHOLE:
|
case STATIC_IPV4_BLACKHOLE:
|
||||||
rib_nexthop_blackhole_add (rib);
|
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;
|
nh_p.u.prefix6 = si->addr.ipv6;
|
||||||
zebra_register_rnh_static_nh(&nh_p, rn);
|
zebra_register_rnh_static_nh(&nh_p, rn);
|
||||||
break;
|
break;
|
||||||
case STATIC_IPV6_IFNAME:
|
case STATIC_IPV6_GATEWAY_IFINDEX:
|
||||||
rib_nexthop_ifname_add (rib, si->ifname);
|
rib_nexthop_ipv6_ifindex_add (rib, &si->addr.ipv6, si->ifindex);
|
||||||
break;
|
|
||||||
case STATIC_IPV6_GATEWAY_IFNAME:
|
|
||||||
rib_nexthop_ipv6_ifname_add (rib, &si->addr.ipv6, si->ifname);
|
|
||||||
break;
|
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;
|
nh_p.u.prefix4 = si->addr.ipv4;
|
||||||
zebra_register_rnh_static_nh(&nh_p, rn);
|
zebra_register_rnh_static_nh(&nh_p, rn);
|
||||||
break;
|
break;
|
||||||
case STATIC_IPV4_IFNAME:
|
case STATIC_IFINDEX:
|
||||||
rib_nexthop_ifname_add (rib, si->ifname);
|
rib_nexthop_ifindex_add (rib, si->ifindex);
|
||||||
break;
|
break;
|
||||||
case STATIC_IPV4_BLACKHOLE:
|
case STATIC_IPV4_BLACKHOLE:
|
||||||
rib_nexthop_blackhole_add (rib);
|
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;
|
nh_p.u.prefix6 = si->addr.ipv6;
|
||||||
zebra_register_rnh_static_nh(&nh_p, rn);
|
zebra_register_rnh_static_nh(&nh_p, rn);
|
||||||
break;
|
break;
|
||||||
case STATIC_IPV6_IFNAME:
|
case STATIC_IPV6_GATEWAY_IFINDEX:
|
||||||
rib_nexthop_ifname_add (rib, si->ifname);
|
rib_nexthop_ipv6_ifindex_add (rib, &si->addr.ipv6, si->ifindex);
|
||||||
break;
|
|
||||||
case STATIC_IPV6_GATEWAY_IFNAME:
|
|
||||||
rib_nexthop_ipv6_ifname_add (rib, &si->addr.ipv6, si->ifname);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2718,9 +2656,9 @@ static_nexthop_same (struct nexthop *nexthop, struct static_route *si)
|
|||||||
&& si->type == STATIC_IPV4_GATEWAY
|
&& si->type == STATIC_IPV4_GATEWAY
|
||||||
&& IPV4_ADDR_SAME (&nexthop->gate.ipv4, &si->addr.ipv4))
|
&& IPV4_ADDR_SAME (&nexthop->gate.ipv4, &si->addr.ipv4))
|
||||||
return 1;
|
return 1;
|
||||||
if (nexthop->type == NEXTHOP_TYPE_IFNAME
|
if (nexthop->type == NEXTHOP_TYPE_IFINDEX
|
||||||
&& si->type == STATIC_IPV4_IFNAME
|
&& si->type == STATIC_IFINDEX
|
||||||
&& strcmp (nexthop->ifname, si->ifname) == 0)
|
&& nexthop->ifindex == si->ifindex)
|
||||||
return 1;
|
return 1;
|
||||||
if (nexthop->type == NEXTHOP_TYPE_BLACKHOLE
|
if (nexthop->type == NEXTHOP_TYPE_BLACKHOLE
|
||||||
&& si->type == STATIC_IPV4_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
|
&& si->type == STATIC_IPV6_GATEWAY
|
||||||
&& IPV6_ADDR_SAME (&nexthop->gate.ipv6, &si->addr.ipv6))
|
&& IPV6_ADDR_SAME (&nexthop->gate.ipv6, &si->addr.ipv6))
|
||||||
return 1;
|
return 1;
|
||||||
if (nexthop->type == NEXTHOP_TYPE_IFNAME
|
if (nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX
|
||||||
&& si->type == STATIC_IPV6_IFNAME
|
&& si->type == STATIC_IPV6_GATEWAY_IFINDEX
|
||||||
&& strcmp (nexthop->ifname, si->ifname) == 0)
|
|
||||||
return 1;
|
|
||||||
if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME
|
|
||||||
&& si->type == STATIC_IPV6_GATEWAY_IFNAME
|
|
||||||
&& IPV6_ADDR_SAME (&nexthop->gate.ipv6, &si->addr.ipv6)
|
&& IPV6_ADDR_SAME (&nexthop->gate.ipv6, &si->addr.ipv6)
|
||||||
&& strcmp (nexthop->ifname, si->ifname) == 0)
|
&& nexthop->ifindex == si->ifindex)
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
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. */
|
/* Add static route into static route configuration. */
|
||||||
int
|
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 flags, u_short tag, u_char distance, vrf_id_t vrf_id)
|
||||||
{
|
{
|
||||||
u_char type = 0;
|
u_char type = 0;
|
||||||
@ -2868,8 +2802,8 @@ static_add_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname,
|
|||||||
/* Make flags. */
|
/* Make flags. */
|
||||||
if (gate)
|
if (gate)
|
||||||
type = STATIC_IPV4_GATEWAY;
|
type = STATIC_IPV4_GATEWAY;
|
||||||
else if (ifname)
|
else if (ifindex)
|
||||||
type = STATIC_IPV4_IFNAME;
|
type = STATIC_IFINDEX;
|
||||||
else
|
else
|
||||||
type = STATIC_IPV4_BLACKHOLE;
|
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
|
if (type == si->type
|
||||||
&& (! gate || IPV4_ADDR_SAME (gate, &si->addr.ipv4))
|
&& (! 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))
|
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. */
|
/* Distance or tag changed. */
|
||||||
if (update)
|
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. */
|
/* Make new static route structure. */
|
||||||
si = XCALLOC (MTYPE_STATIC_ROUTE, sizeof (struct static_route));
|
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->flags = flags;
|
||||||
si->tag = tag;
|
si->tag = tag;
|
||||||
si->vrf_id = vrf_id;
|
si->vrf_id = vrf_id;
|
||||||
|
si->ifindex = ifindex;
|
||||||
|
|
||||||
if (gate)
|
if (gate)
|
||||||
si->addr.ipv4 = *gate;
|
si->addr.ipv4 = *gate;
|
||||||
if (ifname)
|
|
||||||
si->ifname = XSTRDUP (0, ifname);
|
|
||||||
|
|
||||||
/* Add new static route information to the tree with sort by
|
/* Add new static route information to the tree with sort by
|
||||||
distance value and gateway address. */
|
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. */
|
/* Delete static route from static route configuration. */
|
||||||
int
|
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_short tag, u_char distance, vrf_id_t vrf_id)
|
||||||
{
|
{
|
||||||
u_char type = 0;
|
u_char type = 0;
|
||||||
@ -2964,8 +2897,8 @@ static_delete_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname,
|
|||||||
/* Make flags. */
|
/* Make flags. */
|
||||||
if (gate)
|
if (gate)
|
||||||
type = STATIC_IPV4_GATEWAY;
|
type = STATIC_IPV4_GATEWAY;
|
||||||
else if (ifname)
|
else if (ifindex)
|
||||||
type = STATIC_IPV4_IFNAME;
|
type = STATIC_IFINDEX;
|
||||||
else
|
else
|
||||||
type = STATIC_IPV4_BLACKHOLE;
|
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)
|
for (si = rn->info; si; si = si->next)
|
||||||
if (type == si->type
|
if (type == si->type
|
||||||
&& (! gate || IPV4_ADDR_SAME (gate, &si->addr.ipv4))
|
&& (! gate || IPV4_ADDR_SAME (gate, &si->addr.ipv4))
|
||||||
&& (! ifname || strcmp (ifname, si->ifname) == 0)
|
&& (! ifindex || ifindex == si->ifindex)
|
||||||
&& (! tag || (tag == si->tag)))
|
&& (! tag || (tag == si->tag)))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2997,8 +2930,6 @@ static_delete_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname,
|
|||||||
route_unlock_node (rn);
|
route_unlock_node (rn);
|
||||||
|
|
||||||
/* Free static route configuration. */
|
/* Free static route configuration. */
|
||||||
if (ifname)
|
|
||||||
XFREE (0, si->ifname);
|
|
||||||
XFREE (MTYPE_STATIC_ROUTE, si);
|
XFREE (MTYPE_STATIC_ROUTE, si);
|
||||||
|
|
||||||
route_unlock_node (rn);
|
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. */
|
/* Add static route into static route configuration. */
|
||||||
int
|
int
|
||||||
static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
|
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)
|
u_char distance, vrf_id_t vrf_id)
|
||||||
{
|
{
|
||||||
struct route_node *rn;
|
struct route_node *rn;
|
||||||
@ -3410,11 +3341,11 @@ static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!gate &&
|
if (!gate &&
|
||||||
(type == STATIC_IPV6_GATEWAY || type == STATIC_IPV6_GATEWAY_IFNAME))
|
(type == STATIC_IPV6_GATEWAY || type == STATIC_IPV6_GATEWAY_IFINDEX))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!ifname &&
|
if (!ifindex &&
|
||||||
(type == STATIC_IPV6_GATEWAY_IFNAME || type == STATIC_IPV6_IFNAME))
|
(type == STATIC_IPV6_GATEWAY_IFINDEX || type == STATIC_IFINDEX))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Lookup static route prefix. */
|
/* 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
|
if (type == si->type
|
||||||
&& (! gate || IPV6_ADDR_SAME (gate, &si->addr.ipv6))
|
&& (! 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))
|
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. */
|
/* Distance or tag changed. */
|
||||||
if (update)
|
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. */
|
/* Make new static route structure. */
|
||||||
si = XCALLOC (MTYPE_STATIC_ROUTE, sizeof (struct static_route));
|
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->flags = flags;
|
||||||
si->tag = tag;
|
si->tag = tag;
|
||||||
si->vrf_id = vrf_id;
|
si->vrf_id = vrf_id;
|
||||||
|
si->ifindex = ifindex;
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case STATIC_IPV6_GATEWAY:
|
case STATIC_IPV6_GATEWAY:
|
||||||
si->addr.ipv6 = *gate;
|
si->addr.ipv6 = *gate;
|
||||||
break;
|
break;
|
||||||
case STATIC_IPV6_IFNAME:
|
case STATIC_IPV6_GATEWAY_IFINDEX:
|
||||||
si->ifname = XSTRDUP (0, ifname);
|
|
||||||
break;
|
|
||||||
case STATIC_IPV6_GATEWAY_IFNAME:
|
|
||||||
si->addr.ipv6 = *gate;
|
si->addr.ipv6 = *gate;
|
||||||
si->ifname = XSTRDUP (0, ifname);
|
|
||||||
break;
|
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. */
|
/* Delete static route from static route configuration. */
|
||||||
int
|
int
|
||||||
static_delete_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
|
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)
|
vrf_id_t vrf_id)
|
||||||
{
|
{
|
||||||
struct route_node *rn;
|
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
|
if (distance == si->distance
|
||||||
&& type == si->type
|
&& type == si->type
|
||||||
&& (! gate || IPV6_ADDR_SAME (gate, &si->addr.ipv6))
|
&& (! gate || IPV6_ADDR_SAME (gate, &si->addr.ipv6))
|
||||||
&& (! ifname || strcmp (ifname, si->ifname) == 0)
|
&& (! ifindex || ifindex == si->ifindex)
|
||||||
&& (! tag || (tag == si->tag)))
|
&& (! tag || (tag == si->tag)))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -3538,8 +3466,6 @@ static_delete_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
|
|||||||
si->next->prev = si->prev;
|
si->next->prev = si->prev;
|
||||||
|
|
||||||
/* Free static route configuration. */
|
/* Free static route configuration. */
|
||||||
if (ifname)
|
|
||||||
XFREE (0, si->ifname);
|
|
||||||
XFREE (MTYPE_STATIC_ROUTE, si);
|
XFREE (MTYPE_STATIC_ROUTE, si);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1210,11 +1210,9 @@ route_match_ip_next_hop (void *rule, struct prefix *prefix,
|
|||||||
|
|
||||||
switch (nh_data->nexthop->type) {
|
switch (nh_data->nexthop->type) {
|
||||||
case NEXTHOP_TYPE_IFINDEX:
|
case NEXTHOP_TYPE_IFINDEX:
|
||||||
case NEXTHOP_TYPE_IFNAME:
|
|
||||||
/* Interface routes can't match ip next-hop */
|
/* Interface routes can't match ip next-hop */
|
||||||
return RMAP_NOMATCH;
|
return RMAP_NOMATCH;
|
||||||
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
||||||
case NEXTHOP_TYPE_IPV4_IFNAME:
|
|
||||||
case NEXTHOP_TYPE_IPV4:
|
case NEXTHOP_TYPE_IPV4:
|
||||||
p.family = AF_INET;
|
p.family = AF_INET;
|
||||||
p.prefix = nh_data->nexthop->gate.ipv4;
|
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) {
|
switch (nh_data->nexthop->type) {
|
||||||
case NEXTHOP_TYPE_IFINDEX:
|
case NEXTHOP_TYPE_IFINDEX:
|
||||||
case NEXTHOP_TYPE_IFNAME:
|
|
||||||
/* Interface routes can't match ip next-hop */
|
/* Interface routes can't match ip next-hop */
|
||||||
return RMAP_NOMATCH;
|
return RMAP_NOMATCH;
|
||||||
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
||||||
case NEXTHOP_TYPE_IPV4_IFNAME:
|
|
||||||
case NEXTHOP_TYPE_IPV4:
|
case NEXTHOP_TYPE_IPV4:
|
||||||
p.family = AF_INET;
|
p.family = AF_INET;
|
||||||
p.prefix = nh_data->nexthop->gate.ipv4;
|
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) {
|
switch (nh_data->nexthop->type) {
|
||||||
case NEXTHOP_TYPE_IFINDEX:
|
case NEXTHOP_TYPE_IFINDEX:
|
||||||
case NEXTHOP_TYPE_IFNAME:
|
|
||||||
/* Interface routes can't match ip next-hop */
|
/* Interface routes can't match ip next-hop */
|
||||||
return RMAP_NOMATCH;
|
return RMAP_NOMATCH;
|
||||||
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
||||||
case NEXTHOP_TYPE_IPV4_IFNAME:
|
|
||||||
case NEXTHOP_TYPE_IPV4:
|
case NEXTHOP_TYPE_IPV4:
|
||||||
p.family = AF_INET;
|
p.family = AF_INET;
|
||||||
p.prefix = nh_data->nexthop->gate.ipv4;
|
p.prefix = nh_data->nexthop->gate.ipv4;
|
||||||
|
@ -493,8 +493,7 @@ ipFwTable (struct variable *v, oid objid[], size_t *objid_len,
|
|||||||
return (u_char *)&nexthop->ifindex;
|
return (u_char *)&nexthop->ifindex;
|
||||||
break;
|
break;
|
||||||
case IPFORWARDTYPE:
|
case IPFORWARDTYPE:
|
||||||
if (nexthop->type == NEXTHOP_TYPE_IFINDEX
|
if (nexthop->type == NEXTHOP_TYPE_IFINDEX)
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IFNAME)
|
|
||||||
result = 3;
|
result = 3;
|
||||||
else
|
else
|
||||||
result = 4;
|
result = 4;
|
||||||
|
@ -49,11 +49,11 @@ zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str,
|
|||||||
struct prefix p;
|
struct prefix p;
|
||||||
struct in_addr gate;
|
struct in_addr gate;
|
||||||
struct in_addr mask;
|
struct in_addr mask;
|
||||||
const char *ifname;
|
|
||||||
u_char flag = 0;
|
u_char flag = 0;
|
||||||
u_short tag = 0;
|
u_short tag = 0;
|
||||||
vrf_id_t vrf_id = VRF_DEFAULT;
|
vrf_id_t vrf_id = VRF_DEFAULT;
|
||||||
|
unsigned int ifindex = 0;
|
||||||
|
|
||||||
ret = str2prefix (dest_str, &p);
|
ret = str2prefix (dest_str, &p);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
{
|
{
|
||||||
@ -99,9 +99,9 @@ zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str,
|
|||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
}
|
}
|
||||||
if (add_cmd)
|
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
|
else
|
||||||
static_delete_ipv4 (&p, NULL, NULL, tag, distance, vrf_id);
|
static_delete_ipv4 (&p, NULL, ifindex, tag, distance, vrf_id);
|
||||||
return CMD_SUCCESS;
|
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 (gate_str == NULL)
|
||||||
{
|
{
|
||||||
if (add_cmd)
|
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
|
else
|
||||||
static_delete_ipv4 (&p, NULL, NULL, tag, distance, vrf_id);
|
static_delete_ipv4 (&p, NULL, ifindex, tag, distance, vrf_id);
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
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
|
/* When gateway is A.B.C.D format, gate is treated as nexthop
|
||||||
address other case gate is treated as interface name. */
|
address other case gate is treated as interface name. */
|
||||||
ret = inet_aton (gate_str, &gate);
|
ret = inet_aton (gate_str, &gate);
|
||||||
if (ret)
|
if (!ret)
|
||||||
ifname = NULL;
|
{
|
||||||
else
|
struct interface *ifp = if_lookup_by_name_vrf (gate_str, vrf_id);
|
||||||
ifname = gate_str;
|
if (!ifp)
|
||||||
|
{
|
||||||
|
vty_out (vty, "%% Unknown interface: %s%s", gate_str, VTY_NEWLINE);
|
||||||
|
return CMD_WARNING;
|
||||||
|
}
|
||||||
|
ifindex = ifp->ifindex;
|
||||||
|
}
|
||||||
|
|
||||||
if (add_cmd)
|
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
|
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;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -1818,12 +1824,9 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn)
|
|||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
case NEXTHOP_TYPE_IPV6:
|
case NEXTHOP_TYPE_IPV6:
|
||||||
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
||||||
case NEXTHOP_TYPE_IPV6_IFNAME:
|
|
||||||
vty_out (vty, " %s",
|
vty_out (vty, " %s",
|
||||||
inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
|
inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
|
||||||
if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
|
if (nexthop->ifindex)
|
||||||
vty_out (vty, ", %s", nexthop->ifname);
|
|
||||||
else if (nexthop->ifindex)
|
|
||||||
vty_out (vty, ", via %s",
|
vty_out (vty, ", via %s",
|
||||||
ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
|
ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
|
||||||
break;
|
break;
|
||||||
@ -1832,9 +1835,6 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn)
|
|||||||
vty_out (vty, " directly connected, %s",
|
vty_out (vty, " directly connected, %s",
|
||||||
ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
|
ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
|
||||||
break;
|
break;
|
||||||
case NEXTHOP_TYPE_IFNAME:
|
|
||||||
vty_out (vty, " directly connected, %s", nexthop->ifname);
|
|
||||||
break;
|
|
||||||
case NEXTHOP_TYPE_BLACKHOLE:
|
case NEXTHOP_TYPE_BLACKHOLE:
|
||||||
vty_out (vty, " directly connected, Null0");
|
vty_out (vty, " directly connected, Null0");
|
||||||
break;
|
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:
|
||||||
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
||||||
case NEXTHOP_TYPE_IPV4_IFNAME:
|
|
||||||
if (nexthop->src.ipv4.s_addr)
|
if (nexthop->src.ipv4.s_addr)
|
||||||
{
|
{
|
||||||
if (inet_ntop(AF_INET, &nexthop->src.ipv4, addrstr,
|
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);
|
vty_out (vty, ", src %s", addrstr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
case NEXTHOP_TYPE_IPV6:
|
case NEXTHOP_TYPE_IPV6:
|
||||||
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
||||||
case NEXTHOP_TYPE_IPV6_IFNAME:
|
|
||||||
if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
|
if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
|
||||||
{
|
{
|
||||||
if (inet_ntop(AF_INET6, &nexthop->src.ipv6, addrstr,
|
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);
|
vty_out (vty, ", src %s", addrstr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif /* HAVE_IPV6 */
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1935,12 +1931,9 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
|
|||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
case NEXTHOP_TYPE_IPV6:
|
case NEXTHOP_TYPE_IPV6:
|
||||||
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
||||||
case NEXTHOP_TYPE_IPV6_IFNAME:
|
|
||||||
vty_out (vty, " via %s",
|
vty_out (vty, " via %s",
|
||||||
inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
|
inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
|
||||||
if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
|
if (nexthop->ifindex)
|
||||||
vty_out (vty, ", %s", nexthop->ifname);
|
|
||||||
else if (nexthop->ifindex)
|
|
||||||
vty_out (vty, ", %s",
|
vty_out (vty, ", %s",
|
||||||
ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
|
ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
|
||||||
break;
|
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",
|
vty_out (vty, " is directly connected, %s",
|
||||||
ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
|
ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
|
||||||
break;
|
break;
|
||||||
case NEXTHOP_TYPE_IFNAME:
|
|
||||||
vty_out (vty, " is directly connected, %s", nexthop->ifname);
|
|
||||||
break;
|
|
||||||
case NEXTHOP_TYPE_BLACKHOLE:
|
case NEXTHOP_TYPE_BLACKHOLE:
|
||||||
vty_out (vty, " is directly connected, Null0");
|
vty_out (vty, " is directly connected, Null0");
|
||||||
break;
|
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:
|
||||||
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
||||||
case NEXTHOP_TYPE_IPV4_IFNAME:
|
|
||||||
if (nexthop->src.ipv4.s_addr)
|
if (nexthop->src.ipv4.s_addr)
|
||||||
{
|
{
|
||||||
if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
|
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
|
#ifdef HAVE_IPV6
|
||||||
case NEXTHOP_TYPE_IPV6:
|
case NEXTHOP_TYPE_IPV6:
|
||||||
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
||||||
case NEXTHOP_TYPE_IPV6_IFNAME:
|
|
||||||
if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
|
if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
|
||||||
{
|
{
|
||||||
if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
|
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:
|
case STATIC_IPV4_GATEWAY:
|
||||||
vty_out (vty, " %s", inet_ntoa (si->addr.ipv4));
|
vty_out (vty, " %s", inet_ntoa (si->addr.ipv4));
|
||||||
break;
|
break;
|
||||||
case STATIC_IPV4_IFNAME:
|
case STATIC_IFINDEX:
|
||||||
vty_out (vty, " %s", si->ifname);
|
vty_out (vty, " %s", ifindex2ifname_vrf(si->ifindex, si->vrf_id));
|
||||||
break;
|
break;
|
||||||
case STATIC_IPV4_BLACKHOLE:
|
case STATIC_IPV4_BLACKHOLE:
|
||||||
vty_out (vty, " Null0");
|
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;
|
vrf_id_t vrf_id = VRF_DEFAULT;
|
||||||
u_char flag = 0;
|
u_char flag = 0;
|
||||||
u_short tag = 0;
|
u_short tag = 0;
|
||||||
|
unsigned int ifindex = 0;
|
||||||
|
struct interface *ifp = NULL;
|
||||||
|
|
||||||
ret = str2prefix (dest_str, &p);
|
ret = str2prefix (dest_str, &p);
|
||||||
if (ret <= 0)
|
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);
|
vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
}
|
}
|
||||||
type = STATIC_IPV6_GATEWAY_IFNAME;
|
type = STATIC_IPV6_GATEWAY_IFINDEX;
|
||||||
gate = &gate_addr;
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -3241,8 +3238,14 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
type = STATIC_IPV6_IFNAME;
|
type = STATIC_IFINDEX;
|
||||||
ifname = gate_str;
|
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);
|
VTY_GET_INTEGER ("VRF ID", vrf_id, vrf_id_str);
|
||||||
|
|
||||||
if (add_cmd)
|
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
|
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;
|
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:
|
||||||
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
||||||
case NEXTHOP_TYPE_IPV6_IFNAME:
|
|
||||||
vty_out (vty, " %s",
|
vty_out (vty, " %s",
|
||||||
inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
|
inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
|
||||||
if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
|
if (nexthop->ifindex)
|
||||||
vty_out (vty, ", %s", nexthop->ifname);
|
|
||||||
else if (nexthop->ifindex)
|
|
||||||
vty_out (vty, ", via %s", ifindex2ifname (nexthop->ifindex));
|
vty_out (vty, ", via %s", ifindex2ifname (nexthop->ifindex));
|
||||||
break;
|
break;
|
||||||
case NEXTHOP_TYPE_IFINDEX:
|
case NEXTHOP_TYPE_IFINDEX:
|
||||||
vty_out (vty, " directly connected, %s",
|
vty_out (vty, " directly connected, %s",
|
||||||
ifindex2ifname (nexthop->ifindex));
|
ifindex2ifname (nexthop->ifindex));
|
||||||
break;
|
break;
|
||||||
case NEXTHOP_TYPE_IFNAME:
|
|
||||||
vty_out (vty, " directly connected, %s",
|
|
||||||
nexthop->ifname);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -4395,22 +4391,15 @@ vty_show_ipv6_route (struct vty *vty, struct route_node *rn,
|
|||||||
{
|
{
|
||||||
case NEXTHOP_TYPE_IPV6:
|
case NEXTHOP_TYPE_IPV6:
|
||||||
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
||||||
case NEXTHOP_TYPE_IPV6_IFNAME:
|
|
||||||
vty_out (vty, " via %s",
|
vty_out (vty, " via %s",
|
||||||
inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
|
inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
|
||||||
if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
|
if (nexthop->ifindex)
|
||||||
vty_out (vty, ", %s", nexthop->ifname);
|
|
||||||
else if (nexthop->ifindex)
|
|
||||||
vty_out (vty, ", %s", ifindex2ifname (nexthop->ifindex));
|
vty_out (vty, ", %s", ifindex2ifname (nexthop->ifindex));
|
||||||
break;
|
break;
|
||||||
case NEXTHOP_TYPE_IFINDEX:
|
case NEXTHOP_TYPE_IFINDEX:
|
||||||
vty_out (vty, " is directly connected, %s",
|
vty_out (vty, " is directly connected, %s",
|
||||||
ifindex2ifname (nexthop->ifindex));
|
ifindex2ifname (nexthop->ifindex));
|
||||||
break;
|
break;
|
||||||
case NEXTHOP_TYPE_IFNAME:
|
|
||||||
vty_out (vty, " is directly connected, %s",
|
|
||||||
nexthop->ifname);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -5189,12 +5178,13 @@ static_config_ipv6 (struct vty *vty)
|
|||||||
case STATIC_IPV6_GATEWAY:
|
case STATIC_IPV6_GATEWAY:
|
||||||
vty_out (vty, " %s", inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ));
|
vty_out (vty, " %s", inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ));
|
||||||
break;
|
break;
|
||||||
case STATIC_IPV6_IFNAME:
|
case STATIC_IFINDEX:
|
||||||
vty_out (vty, " %s", si->ifname);
|
vty_out (vty, " %s", ifindex2ifname_vrf (si->ifindex, si->vrf_id));
|
||||||
break;
|
break;
|
||||||
case STATIC_IPV6_GATEWAY_IFNAME:
|
case STATIC_IPV6_GATEWAY_IFINDEX:
|
||||||
vty_out (vty, " %s %s",
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -580,17 +580,14 @@ zsend_redistribute_route (int cmd, struct zserv *client, struct prefix *p,
|
|||||||
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
||||||
stream_put_in_addr (s, &nexthop->gate.ipv4);
|
stream_put_in_addr (s, &nexthop->gate.ipv4);
|
||||||
break;
|
break;
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
case NEXTHOP_TYPE_IPV6:
|
case NEXTHOP_TYPE_IPV6:
|
||||||
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
||||||
case NEXTHOP_TYPE_IPV6_IFNAME:
|
|
||||||
/* Only BGP supports IPv4 prefix with IPv6 NH, so kill this */
|
/* Only BGP supports IPv4 prefix with IPv6 NH, so kill this */
|
||||||
if (p->family == AF_INET)
|
if (p->family == AF_INET)
|
||||||
stream_put_in_addr(s, &dummy_nh.gate.ipv4);
|
stream_put_in_addr(s, &dummy_nh.gate.ipv4);
|
||||||
else
|
else
|
||||||
stream_write (s, (u_char *) &nexthop->gate.ipv6, 16);
|
stream_write (s, (u_char *) &nexthop->gate.ipv6, 16);
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
if (cmd == ZEBRA_REDISTRIBUTE_IPV4_ADD
|
if (cmd == ZEBRA_REDISTRIBUTE_IPV4_ADD
|
||||||
|| cmd == ZEBRA_REDISTRIBUTE_IPV4_DEL)
|
|| 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);
|
stream_put (s, &nexthop->gate.ipv6, 16);
|
||||||
break;
|
break;
|
||||||
case ZEBRA_NEXTHOP_IPV6_IFINDEX:
|
case ZEBRA_NEXTHOP_IPV6_IFINDEX:
|
||||||
case ZEBRA_NEXTHOP_IPV6_IFNAME:
|
|
||||||
stream_put (s, &nexthop->gate.ipv6, 16);
|
stream_put (s, &nexthop->gate.ipv6, 16);
|
||||||
stream_putl (s, nexthop->ifindex);
|
stream_putl (s, nexthop->ifindex);
|
||||||
break;
|
break;
|
||||||
case ZEBRA_NEXTHOP_IFINDEX:
|
case ZEBRA_NEXTHOP_IFINDEX:
|
||||||
case ZEBRA_NEXTHOP_IFNAME:
|
|
||||||
stream_putl (s, nexthop->ifindex);
|
stream_putl (s, nexthop->ifindex);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -759,7 +754,6 @@ zsend_ipv4_nexthop_lookup (struct zserv *client, struct in_addr addr,
|
|||||||
stream_putl (s, nexthop->ifindex);
|
stream_putl (s, nexthop->ifindex);
|
||||||
break;
|
break;
|
||||||
case ZEBRA_NEXTHOP_IFINDEX:
|
case ZEBRA_NEXTHOP_IFINDEX:
|
||||||
case ZEBRA_NEXTHOP_IFNAME:
|
|
||||||
stream_putl (s, nexthop->ifindex);
|
stream_putl (s, nexthop->ifindex);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -938,7 +932,6 @@ zsend_ipv4_import_lookup (struct zserv *client, struct prefix_ipv4 *p,
|
|||||||
stream_putl (s, nexthop->ifindex);
|
stream_putl (s, nexthop->ifindex);
|
||||||
break;
|
break;
|
||||||
case ZEBRA_NEXTHOP_IFINDEX:
|
case ZEBRA_NEXTHOP_IFINDEX:
|
||||||
case ZEBRA_NEXTHOP_IFNAME:
|
|
||||||
stream_putl (s, nexthop->ifindex);
|
stream_putl (s, nexthop->ifindex);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1068,7 +1061,6 @@ zread_ipv4_add (struct zserv *client, u_short length, vrf_id_t vrf_id)
|
|||||||
u_char nexthop_type;
|
u_char nexthop_type;
|
||||||
struct stream *s;
|
struct stream *s;
|
||||||
unsigned int ifindex;
|
unsigned int ifindex;
|
||||||
u_char ifname_len;
|
|
||||||
safi_t safi;
|
safi_t safi;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -1111,10 +1103,6 @@ zread_ipv4_add (struct zserv *client, u_short length, vrf_id_t vrf_id)
|
|||||||
ifindex = stream_getl (s);
|
ifindex = stream_getl (s);
|
||||||
rib_nexthop_ifindex_add (rib, ifindex);
|
rib_nexthop_ifindex_add (rib, ifindex);
|
||||||
break;
|
break;
|
||||||
case ZEBRA_NEXTHOP_IFNAME:
|
|
||||||
ifname_len = stream_getc (s);
|
|
||||||
stream_forward_getp (s, ifname_len);
|
|
||||||
break;
|
|
||||||
case ZEBRA_NEXTHOP_IPV4:
|
case ZEBRA_NEXTHOP_IPV4:
|
||||||
nexthop.s_addr = stream_get_ipv4 (s);
|
nexthop.s_addr = stream_get_ipv4 (s);
|
||||||
rib_nexthop_ipv4_add (rib, &nexthop, NULL);
|
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;
|
struct prefix_ipv4 p;
|
||||||
u_char nexthop_num;
|
u_char nexthop_num;
|
||||||
u_char nexthop_type;
|
u_char nexthop_type;
|
||||||
u_char ifname_len;
|
|
||||||
|
|
||||||
s = client->ibuf;
|
s = client->ibuf;
|
||||||
ifindex = 0;
|
ifindex = 0;
|
||||||
@ -1206,10 +1193,6 @@ zread_ipv4_delete (struct zserv *client, u_short length, vrf_id_t vrf_id)
|
|||||||
case ZEBRA_NEXTHOP_IFINDEX:
|
case ZEBRA_NEXTHOP_IFINDEX:
|
||||||
ifindex = stream_getl (s);
|
ifindex = stream_getl (s);
|
||||||
break;
|
break;
|
||||||
case ZEBRA_NEXTHOP_IFNAME:
|
|
||||||
ifname_len = stream_getc (s);
|
|
||||||
stream_forward_getp (s, ifname_len);
|
|
||||||
break;
|
|
||||||
case ZEBRA_NEXTHOP_IPV4:
|
case ZEBRA_NEXTHOP_IPV4:
|
||||||
nexthop.s_addr = stream_get_ipv4 (s);
|
nexthop.s_addr = stream_get_ipv4 (s);
|
||||||
nexthop_p = &nexthop;
|
nexthop_p = &nexthop;
|
||||||
|
Loading…
Reference in New Issue
Block a user