mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-11 13:12:28 +00:00
bgpd: BGP should accept "router-id IFNAME"
ospfd: OSPF should accept "router-id IFNAME" Added commands in BGP and OSPF where user can specify interface for router-id. Ticket: CM-5040 Reviewed By: CCR-4908 Testing Done: Manual
This commit is contained in:
parent
8cdabf90ad
commit
cdb805bc9e
@ -32,6 +32,8 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
|
#include "if.h"
|
||||||
|
#include "vrf.h"
|
||||||
|
|
||||||
#include "bgpd/bgpd.h"
|
#include "bgpd/bgpd.h"
|
||||||
#include "bgpd/bgp_advertise.h"
|
#include "bgpd/bgp_advertise.h"
|
||||||
@ -809,6 +811,10 @@ DEFUN (no_bgp_router_id,
|
|||||||
int ret;
|
int ret;
|
||||||
struct in_addr id;
|
struct in_addr id;
|
||||||
struct bgp *bgp;
|
struct bgp *bgp;
|
||||||
|
struct interface *ifp;
|
||||||
|
struct listnode *node;
|
||||||
|
struct connected *ifc;
|
||||||
|
struct prefix *p;
|
||||||
|
|
||||||
bgp = vty->index;
|
bgp = vty->index;
|
||||||
|
|
||||||
@ -816,16 +822,28 @@ DEFUN (no_bgp_router_id,
|
|||||||
{
|
{
|
||||||
ret = inet_aton (argv[0], &id);
|
ret = inet_aton (argv[0], &id);
|
||||||
if (! ret)
|
if (! ret)
|
||||||
{
|
{
|
||||||
vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE);
|
ifp = if_lookup_by_name_vrf(argv[0], bgp->vrf_id);
|
||||||
return CMD_WARNING;
|
if (!ifp) {
|
||||||
}
|
vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE);
|
||||||
|
return CMD_WARNING;
|
||||||
|
}
|
||||||
|
for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc))
|
||||||
|
{
|
||||||
|
p = ifc->address;
|
||||||
|
if (p && (p->family == AF_INET))
|
||||||
|
{
|
||||||
|
id = p->u.prefix4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id))
|
if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id))
|
||||||
{
|
{
|
||||||
vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE);
|
vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE);
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bgp->router_id_static.s_addr = 0;
|
bgp->router_id_static.s_addr = 0;
|
||||||
@ -842,6 +860,56 @@ ALIAS (no_bgp_router_id,
|
|||||||
"Override configured router identifier\n"
|
"Override configured router identifier\n"
|
||||||
"Manually configured router identifier\n")
|
"Manually configured router identifier\n")
|
||||||
|
|
||||||
|
DEFUN (bgp_router_id_interface,
|
||||||
|
bgp_router_id_interface_cmd,
|
||||||
|
"bgp router-id IFNAME",
|
||||||
|
BGP_STR
|
||||||
|
"Override configured router identifier\n"
|
||||||
|
"Interface name\n")
|
||||||
|
{
|
||||||
|
struct bgp *bgp;
|
||||||
|
struct interface *ifp;
|
||||||
|
struct connected *ifc;
|
||||||
|
struct listnode *node;
|
||||||
|
struct prefix *p;
|
||||||
|
struct vrf *vrf;
|
||||||
|
|
||||||
|
bgp = vty->index;
|
||||||
|
p = NULL;
|
||||||
|
|
||||||
|
ifp = if_lookup_by_name_vrf(argv[0], bgp->vrf_id);
|
||||||
|
if (!ifp)
|
||||||
|
{
|
||||||
|
vrf = vrf_lookup(bgp->vrf_id);
|
||||||
|
vty_out (vty, "%% Couldnt find interface %s in VRF %s%s", argv[0], vrf? vrf->name:"", VTY_NEWLINE);
|
||||||
|
return CMD_WARNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc))
|
||||||
|
{
|
||||||
|
p = ifc->address;
|
||||||
|
|
||||||
|
if (p && (p->family == AF_INET))
|
||||||
|
{
|
||||||
|
if (IPV4_ADDR_SAME (&bgp->router_id_static, &p->u.prefix4))
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
bgp->router_id_static = p->u.prefix4;
|
||||||
|
bgp_router_id_set (bgp, &p->u.prefix4);
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vty_out (vty, "%% Couldnt assign the router-id%s", VTY_NEWLINE);
|
||||||
|
return CMD_WARNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
ALIAS (no_bgp_router_id,
|
||||||
|
no_bgp_router_id_interface_cmd,
|
||||||
|
"no bgp router-id IFNAME",
|
||||||
|
NO_STR
|
||||||
|
BGP_STR
|
||||||
|
"Override configured router identifier\n"
|
||||||
|
"Interface name\n")
|
||||||
|
|
||||||
/* BGP Cluster ID. */
|
/* BGP Cluster ID. */
|
||||||
|
|
||||||
DEFUN (bgp_cluster_id,
|
DEFUN (bgp_cluster_id,
|
||||||
@ -14313,6 +14381,8 @@ bgp_vty_init (void)
|
|||||||
install_element (BGP_NODE, &bgp_router_id_cmd);
|
install_element (BGP_NODE, &bgp_router_id_cmd);
|
||||||
install_element (BGP_NODE, &no_bgp_router_id_cmd);
|
install_element (BGP_NODE, &no_bgp_router_id_cmd);
|
||||||
install_element (BGP_NODE, &no_bgp_router_id_val_cmd);
|
install_element (BGP_NODE, &no_bgp_router_id_val_cmd);
|
||||||
|
install_element (BGP_NODE, &bgp_router_id_interface_cmd);
|
||||||
|
install_element (BGP_NODE, &no_bgp_router_id_interface_cmd);
|
||||||
|
|
||||||
/* "bgp cluster-id" commands. */
|
/* "bgp cluster-id" commands. */
|
||||||
install_element (BGP_NODE, &bgp_cluster_id_cmd);
|
install_element (BGP_NODE, &bgp_cluster_id_cmd);
|
||||||
|
@ -271,10 +271,43 @@ DEFUN (no_ospf_router_id,
|
|||||||
struct ospf *ospf = vty->index;
|
struct ospf *ospf = vty->index;
|
||||||
struct listnode *node;
|
struct listnode *node;
|
||||||
struct ospf_area *area;
|
struct ospf_area *area;
|
||||||
|
struct in_addr id;
|
||||||
|
struct interface *ifp;
|
||||||
|
struct connected *ifc;
|
||||||
|
struct prefix *p;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!ospf)
|
if (!ospf)
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
|
|
||||||
|
if (argc == 1)
|
||||||
|
{
|
||||||
|
ret = inet_aton (argv[0], &id);
|
||||||
|
if (! ret)
|
||||||
|
{
|
||||||
|
ifp = if_lookup_by_name(argv[0]);
|
||||||
|
if (!ifp) {
|
||||||
|
vty_out (vty, "%% Malformed OSPF router identifier%s", VTY_NEWLINE);
|
||||||
|
return CMD_WARNING;
|
||||||
|
}
|
||||||
|
for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc))
|
||||||
|
{
|
||||||
|
p = ifc->address;
|
||||||
|
if (p && (p->family == AF_INET))
|
||||||
|
{
|
||||||
|
id = p->u.prefix4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! IPV4_ADDR_SAME (&ospf->router_id_static, &id))
|
||||||
|
{
|
||||||
|
vty_out (vty, "%% OSPF router-id doesn't match%s", VTY_NEWLINE);
|
||||||
|
return CMD_WARNING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ospf->router_id_static.s_addr = 0;
|
ospf->router_id_static.s_addr = 0;
|
||||||
|
|
||||||
for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
|
for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
|
||||||
@ -298,6 +331,63 @@ ALIAS (no_ospf_router_id,
|
|||||||
"router-id for the OSPF process\n"
|
"router-id for the OSPF process\n"
|
||||||
"OSPF router-id in IP address format\n")
|
"OSPF router-id in IP address format\n")
|
||||||
|
|
||||||
|
DEFUN (ospf_router_id_interface,
|
||||||
|
ospf_router_id_interface_cmd,
|
||||||
|
"ospf router-id IFNAME",
|
||||||
|
"OSPF specific commands\n"
|
||||||
|
"router-id for the OSPF process\n"
|
||||||
|
"Interface name\n")
|
||||||
|
{
|
||||||
|
struct ospf *ospf = vty->index;
|
||||||
|
struct listnode *node;
|
||||||
|
struct ospf_area *area;
|
||||||
|
struct interface *ifp;
|
||||||
|
struct connected *ifc;
|
||||||
|
struct prefix *p;
|
||||||
|
|
||||||
|
if (!ospf)
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
|
||||||
|
p = NULL;
|
||||||
|
ifp = if_lookup_by_name(argv[0]);
|
||||||
|
if (!ifp)
|
||||||
|
{
|
||||||
|
vty_out (vty, "%% Couldnt find interface %s%s", argv[0], VTY_NEWLINE);
|
||||||
|
return CMD_WARNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc))
|
||||||
|
{
|
||||||
|
p = ifc->address;
|
||||||
|
|
||||||
|
if (p && (p->family == AF_INET))
|
||||||
|
{
|
||||||
|
if (IPV4_ADDR_SAME (&ospf->router_id_static, &p->u.prefix4))
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
ospf->router_id_static = p->u.prefix4;
|
||||||
|
for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
|
||||||
|
if (area->full_nbrs)
|
||||||
|
{
|
||||||
|
vty_out (vty, "For this router-id change to take effect,"
|
||||||
|
" save config and restart ospfd%s", VTY_NEWLINE);
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
ospf_router_id_update (ospf);
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vty_out (vty, "%% Couldnt assign the router-id%s", VTY_NEWLINE);
|
||||||
|
return CMD_WARNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
ALIAS (no_ospf_router_id,
|
||||||
|
no_ospf_router_id_interface_cmd,
|
||||||
|
"no ospf router-id IFNAME",
|
||||||
|
NO_STR
|
||||||
|
"OSPF specific commands\n"
|
||||||
|
"router-id for the OSPF process\n"
|
||||||
|
"Interface name\n")
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ospf_passive_interface_default (struct ospf *ospf, u_char newval)
|
ospf_passive_interface_default (struct ospf *ospf, u_char newval)
|
||||||
{
|
{
|
||||||
@ -10331,8 +10421,10 @@ ospf_vty_init (void)
|
|||||||
/* "ospf router-id" commands. */
|
/* "ospf router-id" commands. */
|
||||||
install_element (OSPF_NODE, &ospf_router_id_cmd);
|
install_element (OSPF_NODE, &ospf_router_id_cmd);
|
||||||
install_element (OSPF_NODE, &ospf_router_id_old_cmd);
|
install_element (OSPF_NODE, &ospf_router_id_old_cmd);
|
||||||
|
install_element (OSPF_NODE, &ospf_router_id_interface_cmd);
|
||||||
install_element (OSPF_NODE, &no_ospf_router_id_cmd);
|
install_element (OSPF_NODE, &no_ospf_router_id_cmd);
|
||||||
install_element (OSPF_NODE, &no_ospf_router_id_val_cmd);
|
install_element (OSPF_NODE, &no_ospf_router_id_val_cmd);
|
||||||
|
install_element (OSPF_NODE, &no_ospf_router_id_interface_cmd);
|
||||||
|
|
||||||
/* "passive-interface" commands. */
|
/* "passive-interface" commands. */
|
||||||
install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
|
install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
|
||||||
|
Loading…
Reference in New Issue
Block a user