== CHECK_FLAG(peer2->flags, PEER_FLAG_CONFIG_NODE));
}
+void peer_flag_inherit(struct peer *peer, uint32_t flag)
+{
+ bool group_val;
+
+ /* Skip if peer is not a peer-group member. */
+ if (!peer_group_active(peer))
+ return;
+
+ /* Unset override flag to signal inheritance from peer-group. */
+ UNSET_FLAG(peer->flags_override, flag);
+
+ /*
+ * Inherit flag state from peer-group. If the flag of the peer-group is
+ * not being inverted, the peer must inherit the inverse of the current
+ * peer-group flag state.
+ */
+ group_val = CHECK_FLAG(peer->group->conf->flags, flag);
+ if (!CHECK_FLAG(peer->group->conf->flags_invert, flag)
+ && CHECK_FLAG(peer->flags_invert, flag))
+ COND_FLAG(peer->flags, flag, !group_val);
+ else
+ COND_FLAG(peer->flags, flag, group_val);
+}
+
int peer_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, uint32_t flag)
{
return CHECK_FLAG(peer->af_flags[afi][safi], flag);
UNSET_FLAG(peer->af_flags[afi][safi], flag);
}
+static bool peergroup_flag_check(struct peer *peer, uint32_t flag)
+{
+ if (!peer_group_active(peer)) {
+ if (CHECK_FLAG(peer->flags_invert, flag))
+ return !CHECK_FLAG(peer->flags, flag);
+ else
+ return !!CHECK_FLAG(peer->flags, flag);
+ }
+
+ return !!CHECK_FLAG(peer->flags_override, flag);
+}
+
static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi,
uint32_t flag)
{
/* peer flags apply */
peer_dst->flags = peer_src->flags;
+ peer_dst->flags_invert = peer_src->flags_invert;
peer_dst->cap = peer_src->cap;
peer_dst->config = peer_src->config;
/* These are per-peer specific flags and so we must preserve them */
saved_flags |= CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY);
- saved_flags |= CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN);
- peer->flags = conf->flags;
- SET_FLAG(peer->flags, saved_flags);
+ saved_flags |= peer->flags & peer->flags_override;
+
+ peer->flags = conf->flags & ~peer->flags_override;
+ peer->flags |= saved_flags;
+ peer->flags_invert |= conf->flags_invert;
/* peer config apply */
peer->config = conf->config;
{
int found;
int size;
- struct peer_group *group;
- struct peer *tmp_peer;
+ bool invert, member_invert;
+ struct peer *member;
struct listnode *node, *nnode;
struct peer_flag_action action;
memset(&action, 0, sizeof(struct peer_flag_action));
size = sizeof peer_flag_action_list / sizeof(struct peer_flag_action);
+ invert = CHECK_FLAG(peer->flags_invert, flag);
found = peer_flag_action_set(peer_flag_action_list, size, &action,
flag);
- /* No flag action is found. */
+ /* Abort if no flag action exists. */
if (!found)
return BGP_ERR_INVALID_FLAG;
- /* When unset the peer-group member's flag we have to check
- peer-group configuration. */
- if (!set && peer_group_active(peer))
- if (CHECK_FLAG(peer->group->conf->flags, flag)) {
- if (flag == PEER_FLAG_SHUTDOWN)
- return BGP_ERR_PEER_GROUP_SHUTDOWN;
- }
-
- /* Flag conflict check. */
+ /* Check for flag conflict: STRICT_CAP_MATCH && OVERRIDE_CAPABILITY */
if (set && CHECK_FLAG(peer->flags | flag, PEER_FLAG_STRICT_CAP_MATCH)
&& CHECK_FLAG(peer->flags | flag, PEER_FLAG_OVERRIDE_CAPABILITY))
return BGP_ERR_PEER_FLAG_CONFLICT;
+ /* Handle flag updates where desired state matches current state. */
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
- if (set && CHECK_FLAG(peer->flags, flag) == flag)
+ if (set && CHECK_FLAG(peer->flags, flag)) {
+ COND_FLAG(peer->flags_override, flag, !invert);
return 0;
- if (!set && !CHECK_FLAG(peer->flags, flag))
+ }
+
+ if (!set && !CHECK_FLAG(peer->flags, flag)) {
+ COND_FLAG(peer->flags_override, flag, invert);
return 0;
+ }
}
- if (set)
- SET_FLAG(peer->flags, flag);
+ /* Inherit from peer-group or set/unset flags accordingly. */
+ if (peer_group_active(peer) && set == invert)
+ peer_flag_inherit(peer, flag);
else
- UNSET_FLAG(peer->flags, flag);
+ COND_FLAG(peer->flags, flag, set);
+ /* Check if handling a regular peer. */
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
+ /* Update flag override state accordingly. */
+ COND_FLAG(peer->flags_override, flag, set != invert);
+
+ /* Execute flag action on peer. */
if (action.type == peer_change_reset)
peer_flag_modify_action(peer, flag);
+ /* Skip peer-group mechanics for regular peers. */
return 0;
}
- /* peer-group member updates. */
- group = peer->group;
+ /*
+ * Update peer-group members, unless they are explicitely overriding
+ * peer-group configuration.
+ */
+ for (ALL_LIST_ELEMENTS(peer->group->peer, node, nnode, member)) {
+ /* Skip peers with overridden configuration. */
+ if (CHECK_FLAG(member->flags_override, flag))
+ continue;
- for (ALL_LIST_ELEMENTS(group->peer, node, nnode, tmp_peer)) {
+ member_invert = CHECK_FLAG(member->flags_invert, flag);
- if (set && CHECK_FLAG(tmp_peer->flags, flag) == flag)
+ /* Skip peers with equivalent configuration. */
+ if (set != member_invert && CHECK_FLAG(member->flags, flag))
continue;
- if (!set && !CHECK_FLAG(tmp_peer->flags, flag))
+ if (set == member_invert && !CHECK_FLAG(member->flags, flag))
continue;
- if (set)
- SET_FLAG(tmp_peer->flags, flag);
- else
- UNSET_FLAG(tmp_peer->flags, flag);
+ /* Update flag on peer-group member. */
+ COND_FLAG(member->flags, flag, set != member_invert);
+ /* Execute flag action on peer-group member. */
if (action.type == peer_change_reset)
- peer_flag_modify_action(tmp_peer, flag);
+ peer_flag_modify_action(member, flag);
}
+
return 0;
}
if (peer->change_local_as) {
if (!peer_group_active(peer)
|| peer->change_local_as != g_peer->change_local_as
- || (CHECK_FLAG(peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)
- != CHECK_FLAG(g_peer->flags,
- PEER_FLAG_LOCAL_AS_NO_PREPEND))
- || (CHECK_FLAG(peer->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)
- != CHECK_FLAG(g_peer->flags,
- PEER_FLAG_LOCAL_AS_REPLACE_AS))) {
- vty_out(vty, " neighbor %s local-as %u%s%s\n", addr,
- peer->change_local_as,
- CHECK_FLAG(peer->flags,
- PEER_FLAG_LOCAL_AS_NO_PREPEND)
- ? " no-prepend"
- : "",
- CHECK_FLAG(peer->flags,
- PEER_FLAG_LOCAL_AS_REPLACE_AS)
- ? " replace-as"
- : "");
+ || peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)
+ || peergroup_flag_check(peer,
+ PEER_FLAG_LOCAL_AS_REPLACE_AS)) {
+ vty_out(vty, " neighbor %s local-as %u", addr,
+ peer->change_local_as);
+
+ if (peergroup_flag_check(peer,
+ PEER_FLAG_LOCAL_AS_NO_PREPEND))
+ vty_out(vty, " no-prepend");
+ if (peergroup_flag_check(peer,
+ PEER_FLAG_LOCAL_AS_REPLACE_AS))
+ vty_out(vty, " replace-as");
+
+ vty_out(vty, "\n");
}
}
}
/* shutdown */
- if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) {
- if (!peer_group_active(peer)
- || !CHECK_FLAG(g_peer->flags, PEER_FLAG_SHUTDOWN)
- || peer->tx_shutdown_message) {
- if (peer->tx_shutdown_message)
- vty_out(vty,
- " neighbor %s shutdown message %s\n",
- addr, peer->tx_shutdown_message);
- else
- vty_out(vty, " neighbor %s shutdown\n", addr);
- }
+ if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) {
+ if (peer->tx_shutdown_message)
+ vty_out(vty, " neighbor %s shutdown message %s\n", addr,
+ peer->tx_shutdown_message);
+ else
+ vty_out(vty, " neighbor %s shutdown\n", addr);
}
/* bfd */
}
/* passive */
- if (CHECK_FLAG(peer->flags, PEER_FLAG_PASSIVE)) {
- if (!peer_group_active(peer)
- || !CHECK_FLAG(g_peer->flags, PEER_FLAG_PASSIVE)) {
- vty_out(vty, " neighbor %s passive\n", addr);
- }
- }
+ if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE))
+ vty_out(vty, " neighbor %s passive\n", addr);
/* ebgp-multihop */
if (peer->sort != BGP_PEER_IBGP && peer->ttl != 1
}
/* disable-connected-check */
- if (CHECK_FLAG(peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) {
- if (!peer_group_active(peer)
- || !CHECK_FLAG(g_peer->flags,
- PEER_FLAG_DISABLE_CONNECTED_CHECK)) {
- vty_out(vty, " neighbor %s disable-connected-check\n",
- addr);
- }
- }
+ if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK))
+ vty_out(vty, " neighbor %s disable-connected-check\n", addr);
/* enforce-first-as */
- if (CHECK_FLAG(peer->flags, PEER_FLAG_ENFORCE_FIRST_AS)) {
- if (!peer_group_active(peer)
- || !CHECK_FLAG(g_peer->flags, PEER_FLAG_ENFORCE_FIRST_AS)) {
- vty_out(vty, " neighbor %s enforce-first-as\n", addr);
- }
- }
+ if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS))
+ vty_out(vty, " neighbor %s enforce-first-as\n", addr);
/* update-source */
if (peer->update_if) {
}
/* capability dynamic */
- if (CHECK_FLAG(peer->flags, PEER_FLAG_DYNAMIC_CAPABILITY)) {
- if (!peer_group_active(peer)
- || !CHECK_FLAG(g_peer->flags,
- PEER_FLAG_DYNAMIC_CAPABILITY)) {
- vty_out(vty, " neighbor %s capability dynamic\n", addr);
- }
- }
+ if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY))
+ vty_out(vty, " neighbor %s capability dynamic\n", addr);
/* capability extended-nexthop */
- if (peer->ifp && !CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) {
- if (!peer_group_active(peer)
- || !CHECK_FLAG(g_peer->flags, PEER_FLAG_CAPABILITY_ENHE)) {
+ if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) {
+ if (CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE))
vty_out(vty,
" no neighbor %s capability extended-nexthop\n",
addr);
- }
- }
-
- if (!peer->ifp && CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) {
- if (!peer_group_active(peer)
- || !CHECK_FLAG(g_peer->flags, PEER_FLAG_CAPABILITY_ENHE)) {
+ else
vty_out(vty,
" neighbor %s capability extended-nexthop\n",
addr);
- }
}
/* dont-capability-negotiation */
- if (CHECK_FLAG(peer->flags, PEER_FLAG_DONT_CAPABILITY)) {
- if (!peer_group_active(peer)
- || !CHECK_FLAG(g_peer->flags, PEER_FLAG_DONT_CAPABILITY)) {
- vty_out(vty, " neighbor %s dont-capability-negotiate\n",
- addr);
- }
- }
+ if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY))
+ vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr);
/* override-capability */
- if (CHECK_FLAG(peer->flags, PEER_FLAG_OVERRIDE_CAPABILITY)) {
- if (!peer_group_active(peer)
- || !CHECK_FLAG(g_peer->flags,
- PEER_FLAG_OVERRIDE_CAPABILITY)) {
- vty_out(vty, " neighbor %s override-capability\n",
- addr);
- }
- }
+ if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY))
+ vty_out(vty, " neighbor %s override-capability\n", addr);
/* strict-capability-match */
- if (CHECK_FLAG(peer->flags, PEER_FLAG_STRICT_CAP_MATCH)) {
- if (!peer_group_active(peer)
- || !CHECK_FLAG(g_peer->flags, PEER_FLAG_STRICT_CAP_MATCH)) {
- vty_out(vty, " neighbor %s strict-capability-match\n",
- addr);
- }
- }
+ if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH))
+ vty_out(vty, " neighbor %s strict-capability-match\n", addr);
}
/* BGP peer configuration display function. */
int local_asn;
int peer_asn;
const char *peer_address;
+ const char *peer_interface;
const char *peer_group;
};
} filter;
} u;
struct {
- bool invert;
+ bool invert_peer;
+ bool invert_group;
bool use_ibgp;
+ bool use_iface_peer;
} o;
afi_t afi;
.local_asn = 100,
.peer_asn = 200,
.peer_address = "1.1.1.1",
+ .peer_interface = "IP-TEST",
.peer_group = "PG-TEST",
};
/* clang-format off */
static struct test_peer_attr test_peer_attrs[] = {
+ /* Peer Attributes */
+ {
+ .cmd = "capability dynamic",
+ .u.flag = PEER_FLAG_DYNAMIC_CAPABILITY,
+ .type = PEER_AT_GLOBAL_FLAG,
+ },
+ {
+ .cmd = "capability extended-nexthop",
+ .u.flag = PEER_FLAG_CAPABILITY_ENHE,
+ .type = PEER_AT_GLOBAL_FLAG,
+ },
+ {
+ .cmd = "capability extended-nexthop",
+ .u.flag = PEER_FLAG_CAPABILITY_ENHE,
+ .type = PEER_AT_GLOBAL_FLAG,
+ .o.invert_peer = true,
+ .o.use_iface_peer = true,
+ },
+ {
+ .cmd = "disable-connected-check",
+ .u.flag = PEER_FLAG_DISABLE_CONNECTED_CHECK,
+ .type = PEER_AT_GLOBAL_FLAG,
+ },
+ {
+ .cmd = "dont-capability-negotiate",
+ .u.flag = PEER_FLAG_DONT_CAPABILITY,
+ .type = PEER_AT_GLOBAL_FLAG,
+ },
+ {
+ .cmd = "enforce-first-as",
+ .u.flag = PEER_FLAG_ENFORCE_FIRST_AS,
+ .type = PEER_AT_GLOBAL_FLAG,
+ },
+ {
+ .cmd = "override-capability",
+ .u.flag = PEER_FLAG_OVERRIDE_CAPABILITY,
+ .type = PEER_AT_GLOBAL_FLAG,
+ },
+ {
+ .cmd = "passive",
+ .u.flag = PEER_FLAG_PASSIVE,
+ .type = PEER_AT_GLOBAL_FLAG,
+ },
+ {
+ .cmd = "shutdown",
+ .u.flag = PEER_FLAG_SHUTDOWN,
+ .type = PEER_AT_GLOBAL_FLAG,
+ },
+ {
+ .cmd = "strict-capability-match",
+ .u.flag = PEER_FLAG_STRICT_CAP_MATCH,
+ .type = PEER_AT_GLOBAL_FLAG,
+ },
+
+ /* Address Family Attributes */
{
.cmd = "addpath-tx-all-paths",
.u.flag = PEER_FLAG_ADDPATH_TX_ALL_PATHS,
{
.cmd = "send-community",
.u.flag = PEER_FLAG_SEND_COMMUNITY,
- .o.invert = true,
+ .o.invert_peer = true,
+ .o.invert_group = true,
},
{
.cmd = "send-community extended",
.u.flag = PEER_FLAG_SEND_EXT_COMMUNITY,
- .o.invert = true,
+ .o.invert_peer = true,
+ .o.invert_group = true,
},
{
.cmd = "send-community large",
.u.flag = PEER_FLAG_SEND_LARGE_COMMUNITY,
- .o.invert = true,
+ .o.invert_peer = true,
+ .o.invert_group = true,
},
{
.cmd = "soft-reconfiguration inbound",
}
}
+static void test_log(struct test *test, const char *fmt, ...)
+{
+ va_list ap;
+
+ /* Skip logging if test instance has previously failed. */
+ if (test->state != TEST_SUCCESS)
+ return;
+
+ /* Store formatted log message. */
+ va_start(ap, fmt);
+ listnode_add(test->log, str_vprintf(fmt, ap));
+ va_end(ap);
+}
+
static void test_execute(struct test *test, const char *fmt, ...)
{
int ret;
va_end(ap);
}
-static struct test *test_new(const char *desc, bool use_ibgp)
+static struct test *test_new(const char *desc, bool use_ibgp,
+ bool use_iface_peer)
{
struct test *test;
union sockunion su;
test_execute(test, "router bgp %d", cfg.local_asn);
test_execute(test, "no bgp default ipv4-unicast");
test_execute(test, "neighbor %s peer-group", cfg.peer_group);
- test_execute(test, "neighbor %s remote-as %d", cfg.peer_address,
- use_ibgp ? cfg.local_asn : cfg.peer_asn);
+ if (use_iface_peer) {
+ test_execute(test, "neighbor %s interface", cfg.peer_interface);
+ test_execute(test, "neighbor %s remote-as %d",
+ cfg.peer_interface,
+ use_ibgp ? cfg.local_asn : cfg.peer_asn);
+ } else {
+ test_execute(test, "neighbor %s remote-as %d", cfg.peer_address,
+ use_ibgp ? cfg.local_asn : cfg.peer_asn);
+ }
+
if (test->state != TEST_SUCCESS)
return test;
}
/* Fetch peer instance. */
- str2sockunion(cfg.peer_address, &su);
- test->peer = peer_lookup(test->bgp, &su);
+ if (use_iface_peer) {
+ test->peer =
+ peer_lookup_by_conf_if(test->bgp, cfg.peer_interface);
+ } else {
+ str2sockunion(cfg.peer_address, &su);
+ test->peer = peer_lookup(test->bgp, &su);
+ }
if (!test->peer) {
test->state = TEST_INTERNAL_ERROR;
test->error = str_printf(
return test;
};
-static void test_log(struct test *test, const char *fmt, ...)
-{
- va_list ap;
-
- /* Skip logging if test instance has previously failed. */
- if (test->state != TEST_SUCCESS)
- return;
-
- /* Store formatted log message. */
- va_start(ap, fmt);
- listnode_add(test->log, str_vprintf(fmt, ap));
- va_end(ap);
-}
-
static void test_finish(struct test *test)
{
char *msg;
XFREE(MTYPE_TMP, test);
}
-static void test_af_flags(struct test *test, struct peer *peer,
- struct test_peer_attr *attr, bool exp_val,
- bool exp_ovrd)
+static void test_peer_flags(struct test *test, struct peer *peer,
+ struct test_peer_attr *attr, bool exp_val,
+ bool exp_ovrd)
{
bool exp_inv, cur_val, cur_ovrd, cur_inv;
- /* Flip expected values for inverted flags. */
- exp_inv = attr->o.invert;
+ /* Skip execution if test instance has previously failed. */
+ if (test->state != TEST_SUCCESS)
+ return;
+
+ /* Detect if flag is meant to be inverted. */
+ if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
+ exp_inv = attr->o.invert_group;
+ else
+ exp_inv = attr->o.invert_peer;
+
+ /* Flip expected value if flag is inverted. */
exp_val ^= exp_inv;
/* Fetch current state of value, override and invert flags. */
- cur_val = !!CHECK_FLAG(peer->af_flags[attr->afi][attr->safi],
- attr->u.flag);
- cur_ovrd = !!CHECK_FLAG(peer->af_flags_override[attr->afi][attr->safi],
- attr->u.flag);
- cur_inv = !!CHECK_FLAG(peer->af_flags_invert[attr->afi][attr->safi],
- attr->u.flag);
+ if (attr->type == PEER_AT_GLOBAL_FLAG) {
+ cur_val = !!CHECK_FLAG(peer->flags, attr->u.flag);
+ cur_ovrd = !!CHECK_FLAG(peer->flags_override, attr->u.flag);
+ cur_inv = !!CHECK_FLAG(peer->flags_invert, attr->u.flag);
+ } else /* if (attr->type == PEER_AT_AF_FLAG) */ {
+ cur_val = !!CHECK_FLAG(peer->af_flags[attr->afi][attr->safi],
+ attr->u.flag);
+ cur_ovrd = !!CHECK_FLAG(
+ peer->af_flags_override[attr->afi][attr->safi],
+ attr->u.flag);
+ cur_inv = !!CHECK_FLAG(
+ peer->af_flags_invert[attr->afi][attr->safi],
+ attr->u.flag);
+ }
/* Assert expected flag states. */
TEST_ASSERT_EQ(test, cur_val, exp_val);
bool cur_ovrd;
struct bgp_filter *filter;
+ /* Skip execution if test instance has previously failed. */
+ if (test->state != TEST_SUCCESS)
+ return;
+
/* Fetch and assert current state of override flag. */
cur_ovrd = !!CHECK_FLAG(peer->filter_override[attr->afi][attr->safi]
[attr->u.filter.direct],
{
int tc = 1;
const char *type;
- const char *ec = pa->o.invert ? "no " : "";
- const char *dc = pa->o.invert ? "" : "no ";
+ const char *ecp = pa->o.invert_peer ? "no " : "";
+ const char *dcp = pa->o.invert_peer ? "" : "no ";
+ const char *ecg = pa->o.invert_group ? "no " : "";
+ const char *dcg = pa->o.invert_group ? "" : "no ";
const char *peer_cmd = pa->peer_cmd ?: pa->cmd;
const char *group_cmd = pa->group_cmd ?: pa->cmd;
struct peer *p = test->peer;
struct peer_group *g = test->group;
- if (pa->type == PEER_AT_AF_FLAG)
+ if (pa->type == PEER_AT_GLOBAL_FLAG) {
+ type = "peer-flag";
+ } else if (pa->type == PEER_AT_AF_FLAG) {
type = "af-flag";
- else /* if (pa->type == PEER_AT_AF_FILTER) */
+ } else if (pa->type == PEER_AT_AF_FILTER) {
type = "af-filter";
+ } else {
+ test->state = TEST_INTERNAL_ERROR;
+ test->error =
+ str_printf("invalid attribute type: %d", pa->type);
+ return;
+ }
- /* Test Case: Switch active address-family. */
+ /* Test Preparation: Switch active address-family. */
if (pa->type == PEER_AT_AF_FLAG || pa->type == PEER_AT_AF_FILTER) {
test_log(test, "prepare: switch address-family to [%s]",
afi_safi_print(pa->afi, pa->safi));
/* Test Case: Set flag on BGP peer. */
test_log(test, "case %02d: set %s [%s] on [%s]", tc++, type, peer_cmd,
p->host);
- test_execute(test, "%sneighbor %s %s", ec, p->host, peer_cmd);
- test_config_present(test, "%sneighbor %s %s", ec, p->host, peer_cmd);
+ test_execute(test, "%sneighbor %s %s", ecp, p->host, peer_cmd);
+ test_config_present(test, "%sneighbor %s %s", ecp, p->host, peer_cmd);
test_config_absent(test, "neighbor %s %s", g->name, pa->cmd);
- if (pa->type == PEER_AT_AF_FLAG) {
- test_af_flags(test, p, pa, true, true);
- test_af_flags(test, g->conf, pa, false, false);
+ if (pa->type == PEER_AT_GLOBAL_FLAG || pa->type == PEER_AT_AF_FLAG) {
+ test_peer_flags(test, p, pa, true, true);
+ test_peer_flags(test, g->conf, pa, false, false);
} else if (pa->type == PEER_AT_AF_FILTER) {
test_af_filter(test, p, pa, true, true);
test_af_filter(test, g->conf, pa, false, false);
test_log(test, "case %02d: add peer [%s] to group [%s]", tc++, p->host,
g->name);
test_execute(test, "neighbor %s peer-group %s", p->host, g->name);
- test_config_present(test, "neighbor %s peer-group %s", p->host,
- g->name);
- test_config_present(test, "%sneighbor %s %s", ec, p->host, peer_cmd);
+ test_config_present(test, "neighbor %s %speer-group %s", p->host,
+ p->conf_if ? "interface " : "", g->name);
+ test_config_present(test, "%sneighbor %s %s", ecp, p->host, peer_cmd);
test_config_absent(test, "neighbor %s %s", g->name, pa->cmd);
- if (pa->type == PEER_AT_AF_FLAG) {
- test_af_flags(test, p, pa, true, true);
- test_af_flags(test, g->conf, pa, false, false);
+ if (pa->type == PEER_AT_GLOBAL_FLAG || pa->type == PEER_AT_AF_FLAG) {
+ test_peer_flags(test, p, pa, true, true);
+ test_peer_flags(test, g->conf, pa, false, false);
} else if (pa->type == PEER_AT_AF_FILTER) {
test_af_filter(test, p, pa, true, true);
test_af_filter(test, g->conf, pa, false, false);
test_log(test, "case %02d: re-add peer [%s] to group [%s]", tc++,
p->host, g->name);
test_execute(test, "neighbor %s peer-group %s", p->host, g->name);
- test_config_present(test, "neighbor %s peer-group %s", p->host,
- g->name);
- test_config_present(test, "%sneighbor %s %s", ec, p->host, peer_cmd);
+ test_config_present(test, "neighbor %s %speer-group %s", p->host,
+ p->conf_if ? "interface " : "", g->name);
+ test_config_present(test, "%sneighbor %s %s", ecp, p->host, peer_cmd);
test_config_absent(test, "neighbor %s %s", g->name, pa->cmd);
- if (pa->type == PEER_AT_AF_FLAG) {
- test_af_flags(test, p, pa, true, true);
- test_af_flags(test, g->conf, pa, false, false);
+ if (pa->type == PEER_AT_GLOBAL_FLAG || pa->type == PEER_AT_AF_FLAG) {
+ test_peer_flags(test, p, pa, true, true);
+ test_peer_flags(test, g->conf, pa, false, false);
} else if (pa->type == PEER_AT_AF_FILTER) {
test_af_filter(test, p, pa, true, true);
test_af_filter(test, g->conf, pa, false, false);
/* Test Case: Set flag on BGP peer-group. */
test_log(test, "case %02d: set %s [%s] on [%s]", tc++, type, group_cmd,
g->name);
- test_execute(test, "%sneighbor %s %s", ec, g->name, group_cmd);
- test_config_present(test, "%sneighbor %s %s", ec, p->host, peer_cmd);
- test_config_present(test, "%sneighbor %s %s", ec, g->name, group_cmd);
- if (pa->type == PEER_AT_AF_FLAG) {
- test_af_flags(test, p, pa, true, true);
- test_af_flags(test, g->conf, pa, true, false);
+ test_execute(test, "%sneighbor %s %s", ecg, g->name, group_cmd);
+ test_config_present(test, "%sneighbor %s %s", ecp, p->host, peer_cmd);
+ test_config_present(test, "%sneighbor %s %s", ecg, g->name, group_cmd);
+ if (pa->type == PEER_AT_GLOBAL_FLAG || pa->type == PEER_AT_AF_FLAG) {
+ test_peer_flags(test, p, pa, true, true);
+ test_peer_flags(test, g->conf, pa, true, false);
} else if (pa->type == PEER_AT_AF_FILTER) {
test_af_filter(test, p, pa, true, true);
test_af_filter(test, g->conf, pa, true, false);
/* Test Case: Unset flag on BGP peer-group. */
test_log(test, "case %02d: unset %s [%s] on [%s]", tc++, type,
group_cmd, g->name);
- test_execute(test, "%sneighbor %s %s", dc, g->name, group_cmd);
- test_config_present(test, "%sneighbor %s %s", ec, p->host, peer_cmd);
+ test_execute(test, "%sneighbor %s %s", dcg, g->name, group_cmd);
+ test_config_present(test, "%sneighbor %s %s", ecp, p->host, peer_cmd);
test_config_absent(test, "neighbor %s %s", g->name, pa->cmd);
- if (pa->type == PEER_AT_AF_FLAG) {
- test_af_flags(test, p, pa, true, true);
- test_af_flags(test, g->conf, pa, false, false);
+ if (pa->type == PEER_AT_GLOBAL_FLAG || pa->type == PEER_AT_AF_FLAG) {
+ test_peer_flags(test, p, pa, true, true);
+ test_peer_flags(test, g->conf, pa, false, false);
} else if (pa->type == PEER_AT_AF_FILTER) {
test_af_filter(test, p, pa, true, true);
test_af_filter(test, g->conf, pa, false, false);
/* Test Case: Set flag on BGP peer-group. */
test_log(test, "case %02d: set %s [%s] on [%s]", tc++, type, group_cmd,
g->name);
- test_execute(test, "%sneighbor %s %s", ec, g->name, group_cmd);
- test_config_present(test, "%sneighbor %s %s", ec, p->host, peer_cmd);
- test_config_present(test, "%sneighbor %s %s", ec, g->name, group_cmd);
- if (pa->type == PEER_AT_AF_FLAG) {
- test_af_flags(test, p, pa, true, true);
- test_af_flags(test, g->conf, pa, true, false);
+ test_execute(test, "%sneighbor %s %s", ecg, g->name, group_cmd);
+ test_config_present(test, "%sneighbor %s %s", ecp, p->host, peer_cmd);
+ test_config_present(test, "%sneighbor %s %s", ecg, g->name, group_cmd);
+ if (pa->type == PEER_AT_GLOBAL_FLAG || pa->type == PEER_AT_AF_FLAG) {
+ test_peer_flags(test, p, pa, true, true);
+ test_peer_flags(test, g->conf, pa, true, false);
} else if (pa->type == PEER_AT_AF_FILTER) {
test_af_filter(test, p, pa, true, true);
test_af_filter(test, g->conf, pa, true, false);
/* Test Case: Re-set flag on BGP peer. */
test_log(test, "case %02d: re-set %s [%s] on [%s]", tc++, type,
peer_cmd, p->host);
- test_execute(test, "%sneighbor %s %s", ec, p->host, peer_cmd);
- test_config_present(test, "%sneighbor %s %s", ec, p->host, peer_cmd);
- test_config_present(test, "%sneighbor %s %s", ec, g->name, group_cmd);
- if (pa->type == PEER_AT_AF_FLAG) {
- test_af_flags(test, p, pa, true, true);
- test_af_flags(test, g->conf, pa, true, false);
+ test_execute(test, "%sneighbor %s %s", ecp, p->host, peer_cmd);
+ test_config_present(test, "%sneighbor %s %s", ecp, p->host, peer_cmd);
+ test_config_present(test, "%sneighbor %s %s", ecg, g->name, group_cmd);
+ if (pa->type == PEER_AT_GLOBAL_FLAG || pa->type == PEER_AT_AF_FLAG) {
+ test_peer_flags(test, p, pa, true, true);
+ test_peer_flags(test, g->conf, pa, true, false);
} else if (pa->type == PEER_AT_AF_FILTER) {
test_af_filter(test, p, pa, true, true);
test_af_filter(test, g->conf, pa, true, false);
/* Test Case: Unset flag on BGP peer. */
test_log(test, "case %02d: unset %s [%s] on [%s]", tc++, type, peer_cmd,
p->host);
- test_execute(test, "%sneighbor %s %s", dc, p->host, peer_cmd);
+ test_execute(test, "%sneighbor %s %s", dcp, p->host, peer_cmd);
test_config_absent(test, "neighbor %s %s", p->host, pa->cmd);
- test_config_present(test, "%sneighbor %s %s", ec, g->name, group_cmd);
- if (pa->type == PEER_AT_AF_FLAG) {
- test_af_flags(test, p, pa, true, false);
- test_af_flags(test, g->conf, pa, true, false);
+ test_config_present(test, "%sneighbor %s %s", ecg, g->name, group_cmd);
+ if (pa->type == PEER_AT_GLOBAL_FLAG || pa->type == PEER_AT_AF_FLAG) {
+ test_peer_flags(test, p, pa, true, false);
+ test_peer_flags(test, g->conf, pa, true, false);
} else if (pa->type == PEER_AT_AF_FILTER) {
test_af_filter(test, p, pa, true, false);
test_af_filter(test, g->conf, pa, true, false);
/* Test Case: Unset flag on BGP peer-group. */
test_log(test, "case %02d: unset %s [%s] on [%s]", tc++, type,
group_cmd, g->name);
- test_execute(test, "%sneighbor %s %s", dc, g->name, group_cmd);
+ test_execute(test, "%sneighbor %s %s", dcg, g->name, group_cmd);
test_config_absent(test, "neighbor %s %s", p->host, pa->cmd);
test_config_absent(test, "neighbor %s %s", g->name, pa->cmd);
- if (pa->type == PEER_AT_AF_FLAG) {
- test_af_flags(test, p, pa, false, false);
- test_af_flags(test, g->conf, pa, false, false);
+ if (pa->type == PEER_AT_GLOBAL_FLAG || pa->type == PEER_AT_AF_FLAG) {
+ test_peer_flags(test, p, pa, false, false);
+ test_peer_flags(test, g->conf, pa, false, false);
} else if (pa->type == PEER_AT_AF_FILTER) {
test_af_filter(test, p, pa, false, false);
test_af_filter(test, g->conf, pa, false, false);
/* Test Case: Set flag on BGP peer. */
test_log(test, "case %02d: set %s [%s] on [%s]", tc++, type, peer_cmd,
p->host);
- test_execute(test, "%sneighbor %s %s", ec, p->host, peer_cmd);
- test_config_present(test, "%sneighbor %s %s", ec, p->host, peer_cmd);
+ test_execute(test, "%sneighbor %s %s", ecp, p->host, peer_cmd);
+ test_config_present(test, "%sneighbor %s %s", ecp, p->host, peer_cmd);
test_config_absent(test, "neighbor %s %s", g->name, pa->cmd);
- if (pa->type == PEER_AT_AF_FLAG) {
- test_af_flags(test, p, pa, true, true);
- test_af_flags(test, g->conf, pa, false, false);
+ if (pa->type == PEER_AT_GLOBAL_FLAG || pa->type == PEER_AT_AF_FLAG) {
+ test_peer_flags(test, p, pa, true, true);
+ test_peer_flags(test, g->conf, pa, false, false);
} else if (pa->type == PEER_AT_AF_FILTER) {
test_af_filter(test, p, pa, true, true);
test_af_filter(test, g->conf, pa, false, false);
desc = str_printf("peer\\%s", pa->cmd);
/* Initialize new test instance. */
- test = test_new(desc, pa->o.use_ibgp);
+ test = test_new(desc, pa->o.use_ibgp, pa->o.use_iface_peer);
XFREE(MTYPE_TMP, desc);
/* Execute tests and finish test instance. */