if (bgpd_privs.change(ZPRIVS_RAISE))
zlog_err("Can't raise privileges");
sock = vrf_socket(ainfo->ai_family, ainfo->ai_socktype,
- ainfo->ai_protocol, bgp->vrf_id, NULL);
+ ainfo->ai_protocol, bgp->vrf_id,
+ (bgp->inst_type == BGP_INSTANCE_TYPE_VRF ?
+ bgp->name : NULL));
if (bgpd_privs.change(ZPRIVS_LOWER))
zlog_err("Can't lower privileges");
if (sock < 0) {
static int bgp_check_main_socket(bool create, struct bgp *bgp)
{
static int bgp_server_main_created;
- struct listnode *bgpnode, *nbgpnode;
- struct bgp *bgp_temp;
- if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF &&
- vrf_is_mapped_on_netns(bgp->vrf_id))
- return 0;
if (create == true) {
if (bgp_server_main_created)
return 0;
}
if (!bgp_server_main_created)
return 0;
- /* only delete socket on some cases */
- for (ALL_LIST_ELEMENTS(bm->bgp, bgpnode, nbgpnode, bgp_temp)) {
- /* do not count with current bgp */
- if (bgp_temp == bgp)
- continue;
- /* if other instance non VRF, do not delete socket */
- if (bgp_temp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
- return 0;
- /* vrf lite, do not delete socket */
- if (!vrf_is_mapped_on_netns(bgp_temp->vrf_id))
- return 0;
- }
bgp_close();
bgp_server_main_created = 0;
return 0;
/* Create BGP server socket, if listen mode not disabled */
if (!bgp || bgp_option_check(BGP_OPT_NO_LISTEN))
return 0;
- if (bgp->name && bgp->inst_type == BGP_INSTANCE_TYPE_VRF && vrf) {
+ if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) {
/*
* suppress vrf socket
*/
if (create == FALSE) {
- if (vrf_is_mapped_on_netns(vrf->vrf_id))
- bgp_close_vrf_socket(bgp);
- else
- ret = bgp_check_main_socket(create, bgp);
- return ret;
+ bgp_close_vrf_socket(bgp);
+ return 0;
}
+ if (vrf == NULL)
+ return BGP_ERR_INVALID_VALUE;
/* do nothing
* if vrf_id did not change
*/
*/
if (vrf->vrf_id == VRF_UNKNOWN)
return 0;
- /* if BGP VRF instance requested
- * if backend is NETNS, create BGP server socket in the NETNS
- */
- if (vrf_is_mapped_on_netns(bgp->vrf_id)) {
- ret = bgp_socket(bgp, bm->port, bm->address);
- if (ret < 0)
- return BGP_ERR_INVALID_VALUE;
- return 0;
- }
- }
- /* if BGP VRF instance requested or VRF lite backend
- * if BGP non VRF instance, create it
- * if not already done
- */
- return bgp_check_main_socket(create, bgp);
+ ret = bgp_socket(bgp, bm->port, bm->address);
+ if (ret < 0)
+ return BGP_ERR_INVALID_VALUE;
+ return 0;
+ } else
+ return bgp_check_main_socket(create, bgp);
}
/* Called from VTY commands. */
struct listnode *bgpnode, *nbgpnode;
for (ALL_LIST_ELEMENTS(bm->bgp, bgpnode, nbgpnode, bgp)) {
- /* Skip VRFs Lite only, this function will not be
- * invoked without an instance
- * when examining VRFs.
- */
- if ((bgp->inst_type == BGP_INSTANCE_TYPE_VRF)
- && !vrf_is_mapped_on_netns(bgp->vrf_id))
- continue;
-
peer = hash_lookup(bgp->peerhash, &tmp_peer);
-
if (peer)
break;
}