summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/ChangeLog13
-rw-r--r--bgpd/bgp_attr.c10
-rw-r--r--bgpd/bgp_attr.h6
-rw-r--r--bgpd/bgp_route.c110
-rw-r--r--bgpd/bgp_routemap.c170
-rw-r--r--bgpd/bgp_vty.c141
-rw-r--r--bgpd/bgp_zebra.c8
-rw-r--r--bgpd/bgpd.c99
-rw-r--r--bgpd/bgpd.h10
9 files changed, 565 insertions, 2 deletions
diff --git a/bgpd/ChangeLog b/bgpd/ChangeLog
index 97f78caa..236c0b77 100644
--- a/bgpd/ChangeLog
+++ b/bgpd/ChangeLog
@@ -768,6 +768,19 @@
(peer_create) use XSTRDUP
* bgp_packet.c: (bgp_stream_dup) deleted, stream_dup should be used
(various) update -> s/bgp_stream_dup/stream_dup
+
+2005-04-24 Calin Velea <vcalinus@gemenii.ro>
+
+ * bgp_attr.c: Modified attrhash_cmp and attrhash_key_make to use realms
+ * bgp_attr.h: Added realm attribute to attr struct
+ * bgp_route.c: Changed bgp_input_modifier and bgp_import_modifier
+ to apply default realm to routes
+ * bgp_routemap.c: Added realm route map commands
+ * bgp_vty.c: Added neighbor realm commands
+ * bgp_zebra.c: Added API realm message
+ * bgpd.c: Added functions to set default peer realm
+ * bgpd.h: Added flag for peer default realm, peer default realm
+ functions prototypes
2005-04-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index 4c72d80a..72d66b52 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -299,6 +299,11 @@ attrhash_key_make (struct attr *attr)
key += attr->aggregator_addr.s_addr;
key += attr->weight;
+#ifdef SUPPORT_REALMS
+ key += attr->realmto;
+#endif
+
+
key += attr->mp_nexthop_global_in.s_addr;
if (attr->aspath)
key += aspath_key_make (attr->aspath);
@@ -337,6 +342,11 @@ attrhash_cmp (struct attr *attr1, struct attr *attr2)
&& attr1->aggregator_as == attr2->aggregator_as
&& attr1->aggregator_addr.s_addr == attr2->aggregator_addr.s_addr
&& attr1->weight == attr2->weight
+
+#ifdef SUPPORT_REALMS
+ && attr1->realmto == attr2->realmto
+#endif
+
#ifdef HAVE_IPV6
&& attr1->mp_nexthop_len == attr2->mp_nexthop_len
&& IPV6_ADDR_SAME (&attr1->mp_nexthop_global, &attr2->mp_nexthop_global)
diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h
index 777869ce..6f6a1262 100644
--- a/bgpd/bgp_attr.h
+++ b/bgpd/bgp_attr.h
@@ -87,6 +87,12 @@ struct attr
as_t aggregator_as;
u_char origin;
u_char mp_nexthop_len;
+
+#ifdef SUPPORT_REALMS
+ /* Realm used */
+ u_int16_t realmto;
+#endif
+
};
/* Router Reflector related structure. */
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index ce44842e..8216fd4e 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -568,6 +568,19 @@ bgp_cluster_filter (struct peer *peer, struct attr *attr)
}
return 0;
}
+
+#ifdef SUPPORT_REALMS
+
+#define REALM_PEER_AS 0xFFFFA
+#define REALM_ORIGIN_AS 0xFFFFB
+
+/* Attr. Flags and Attr. Type Code. */
+#define AS_HEADER_SIZE 2
+
+/* Two octet is used for AS value. */
+#define AS_VALUE_SIZE sizeof (as_t)
+
+#endif
static int
bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr,
@@ -577,6 +590,44 @@ bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr,
struct bgp_info info;
route_map_result_t ret;
+#ifdef SUPPORT_REALMS
+
+ u_int16_t realm_value = 0;
+ struct aspath *aspath;
+
+ struct assegment *assegment;
+
+
+ /* Apply default realm value. */
+ aspath = attr->aspath;
+
+ if (peer->realm == REALM_PEER_AS)
+ {
+ realm_value = peer->as;
+
+ }
+ else if (peer->realm == REALM_ORIGIN_AS)
+ {
+ if (aspath == NULL || aspath->segments == NULL)
+ return RMAP_PERMIT;
+
+ assegment = aspath->segments;
+
+ while (assegment) {
+ int i;
+
+ for (i = 0; i < assegment->length; i++)
+ realm_value = assegment->as[i];
+
+ assegment = assegment->next;
+ }
+ }
+ else realm_value = (u_int16_t)(peer->realm & 0xFFFF);
+
+ attr->realmto = realm_value;
+
+#endif
+
filter = &peer->filter[afi][safi];
/* Apply default weight value. */
@@ -648,6 +699,46 @@ bgp_import_modifier (struct peer *rsclient, struct peer *peer,
struct bgp_info info;
route_map_result_t ret;
+#ifdef SUPPORT_REALMS
+
+ u_int16_t realm_value = 0;
+ struct aspath *aspath;
+
+ struct assegment *assegment;
+
+
+ /* Apply default realm value. */
+ aspath = attr->aspath;
+
+ if (peer->realm == REALM_PEER_AS)
+ {
+ realm_value = peer->as;
+
+ }
+ else if (peer->realm == REALM_ORIGIN_AS)
+ {
+ if (aspath == NULL || aspath->segments == NULL)
+ return RMAP_PERMIT;
+
+ assegment = aspath->segments;
+
+ while (assegment) {
+ int i;
+
+ for (i = 0; i < assegment->length; i++)
+ realm_value = assegment->as[i];
+
+ assegment = assegment->next;
+ }
+ }
+ else realm_value = (u_int16_t)(peer->realm & 0xFFFF);
+
+ attr->realmto = realm_value;
+
+#endif
+
+
+
filter = &rsclient->filter[afi][safi];
/* Apply default weight value. */
@@ -5206,6 +5297,10 @@ route_vty_out (struct vty *vty, struct prefix *p,
vty_out (vty, "%7u ",attr->weight);
+#ifdef SUPPORT_REALMS
+ vty_out (vty, "%7u ", attr->realmto);
+#endif
+
/* Print aspath */
if (attr->aspath)
aspath_print_vty (vty, "%s ", attr->aspath);
@@ -5267,6 +5362,10 @@ route_vty_out_tmp (struct vty *vty, struct prefix *p,
vty_out (vty, "%7d ",attr->weight);
+#ifdef SUPPORT_REALMS
+ vty_out (vty, "%7u ", attr->realmto);
+#endif
+
/* Print aspath */
if (attr->aspath)
aspath_print_vty (vty, "%s ", attr->aspath);
@@ -5554,6 +5653,13 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
vty_out (vty, ", best");
+#ifdef SUPPORT_REALMS
+ if (attr->realmto) {
+ char realmbuf[64];
+ vty_out (vty, ", realm %s", rtnl_rtrealm_n2a (attr->realmto, realmbuf, sizeof (realmbuf)));
+ }
+#endif
+
vty_out (vty, "%s", VTY_NEWLINE);
/* Line 4 display Community */
@@ -5594,7 +5700,11 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
#define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,%s r RIB-failure, S Stale, R Removed%s"
#define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
+#ifdef SUPPORT_REALMS
+#define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Realm Path%s"
+#else
#define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
+#endif
#define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
#define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index 806a5072..e660568c 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -1119,6 +1119,112 @@ struct route_map_rule_cmd route_set_metric_cmd =
route_set_metric_compile,
route_set_metric_free,
};
+
+#ifdef SUPPORT_REALMS
+/* `set realm REALM' */
+
+#define REALM_PEER_AS 0xFFFFA
+#define REALM_ORIGIN_AS 0xFFFFB
+
+/* Attr. Flags and Attr. Type Code. */
+#define AS_HEADER_SIZE 2
+
+/* Two octet is used for AS value. */
+#define AS_VALUE_SIZE sizeof (as_t)
+
+static route_map_result_t
+route_set_realm (void *rule, struct prefix *prefix,
+ route_map_object_t type, void *object)
+{
+ u_int32_t *realm;
+ u_int16_t realm_value = 0;
+ struct bgp_info *bgp_info;
+ struct aspath *aspath;
+
+ struct assegment *assegment;
+
+ if(type != RMAP_BGP)
+ return RMAP_OKAY;
+
+ bgp_info = object;
+ aspath = bgp_info->attr->aspath;
+ realm = (u_int32_t*) rule;
+
+ if (*realm == REALM_PEER_AS)
+ {
+ if (aspath == NULL || aspath->segments == NULL)
+ return RMAP_OKAY;
+
+ realm_value = bgp_info->peer->as;
+
+ }
+ else if (*realm == REALM_ORIGIN_AS)
+ {
+ if (aspath == NULL || aspath->segments == NULL)
+ return RMAP_PERMIT;
+
+ assegment = aspath->segments;
+
+ while (assegment) {
+ int i;
+
+ for (i = 0; i < assegment->length; i++)
+ realm_value = assegment->as[i];
+
+ assegment = assegment->next;
+ }
+ }
+ else realm_value = (u_int16_t)(*realm & 0xFFFF);
+
+ bgp_info->attr->realmto = realm_value;
+
+ return RMAP_OKAY;
+}
+
+/*
+ * set realm REALM - to set 'to' realm of route
+ */
+static void *
+route_set_realm_compile (char *arg)
+{
+ u_int32_t *realm;
+ u_int32_t realmid;
+
+ if (strcmp(arg, "peer-as") == 0)
+ {
+ realmid = REALM_PEER_AS;
+ }
+ else if (strcmp(arg, "origin-as") == 0)
+ {
+ realmid = REALM_ORIGIN_AS;
+ }
+ else if (rtnl_rtrealm_a2n (&realmid, arg) < 0)
+ {
+ return NULL;
+ }
+
+ realm = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t));
+ *realm = (u_int32_t)realmid;
+
+ return realm;
+}
+
+static void
+route_set_realm_free (void *rule)
+{
+ XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
+}
+
+/* Set realms rule structure. */
+struct route_map_rule_cmd route_set_realm_cmd =
+{
+ "realm",
+ route_set_realm,
+ route_set_realm_compile,
+ route_set_realm_free,
+};
+#endif
+
/* `set as-path prepend ASPATH' */
@@ -2827,6 +2933,59 @@ ALIAS (no_set_metric,
"Metric value for destination routing protocol\n"
"Metric value\n")
+#ifdef SUPPORT_REALMS
+DEFUN (set_realm,
+ set_realm_cmd,
+ "set realm (<1-255>|WORD)",
+ SET_STR
+ "Set realm id or name for Linux FIB routes\n"
+ "Realm id for Linux FIB routes\n"
+ "Realm name for Linux FIB routes\n")
+{
+ return bgp_route_set_add (vty, vty->index, "realm", argv[0]);
+}
+
+ALIAS (set_realm,
+ set_realm_origin_peer_cmd,
+ "set realm (origin-as|peer-as)",
+ MATCH_STR
+ "Set realm for Linux FIB routes\n"
+ "Use route origin AS as realm id\n"
+ "Use route peer AS as realm id\n")
+
+DEFUN (no_set_realm,
+ no_set_realm_cmd,
+ "no set realm",
+ NO_STR
+ SET_STR
+ "Realm value(s) for Linux FIB routes\n")
+{
+ if (argc == 0)
+ return bgp_route_set_delete (vty, vty->index, "realm", NULL);
+
+ return bgp_route_set_delete (vty, vty->index, "realm", argv[0]);
+}
+
+ALIAS (no_set_realm,
+ no_set_realm_val_cmd,
+ "no set realm (<0-255>|WORD)",
+ NO_STR
+ SET_STR
+ "Realm value(s) for Linux FIB routes\n"
+ "Realm value\n"
+ "Realm name\n")
+
+ALIAS (no_set_realm,
+ no_set_realm_origin_peer_cmd,
+ "no set realm (origin-as|peer-as)",
+ NO_STR
+ SET_STR
+ "Realm value(s) for Linux FIB routes\n"
+ "Origin AS - realm\n"
+ "Peer AS - realm\n")
+
+#endif
+
DEFUN (set_local_pref,
set_local_pref_cmd,
"set local-preference <0-4294967295>",
@@ -3554,6 +3713,10 @@ bgp_route_map_init (void)
route_map_install_set (&route_set_local_pref_cmd);
route_map_install_set (&route_set_weight_cmd);
route_map_install_set (&route_set_metric_cmd);
+#ifdef SUPPORT_REALMS
+ route_map_install_set (&route_set_realm_cmd);
+
+#endif
route_map_install_set (&route_set_aspath_prepend_cmd);
route_map_install_set (&route_set_origin_cmd);
route_map_install_set (&route_set_atomic_aggregate_cmd);
@@ -3622,6 +3785,13 @@ bgp_route_map_init (void)
install_element (RMAP_NODE, &set_metric_addsub_cmd);
install_element (RMAP_NODE, &no_set_metric_cmd);
install_element (RMAP_NODE, &no_set_metric_val_cmd);
+#ifdef SUPPORT_REALMS
+ install_element (RMAP_NODE, &set_realm_cmd);
+ install_element (RMAP_NODE, &set_realm_origin_peer_cmd);
+ install_element (RMAP_NODE, &no_set_realm_cmd);
+ install_element (RMAP_NODE, &no_set_realm_val_cmd);
+ install_element (RMAP_NODE, &no_set_realm_origin_peer_cmd);
+#endif
install_element (RMAP_NODE, &set_aspath_prepend_cmd);
install_element (RMAP_NODE, &no_set_aspath_prepend_cmd);
install_element (RMAP_NODE, &no_set_aspath_prepend_val_cmd);
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index b108164f..10c9778e 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -2985,7 +2985,114 @@ ALIAS (no_neighbor_weight,
NEIGHBOR_ADDR_STR2
"Set default weight for routes from this neighbor\n"
"default weight\n")
-
+
+#ifdef SUPPORT_REALMS
+
+#define REALM_PEER_AS 0xFFFFA
+#define REALM_ORIGIN_AS 0xFFFFB
+
+/* neighbor realm.*/
+static int
+peer_realm_set_vty (struct vty *vty, const char *ip_str,
+ const char *realm_str)
+{
+ struct peer *peer;
+ u_int32_t realmid;
+
+ if (strcmp(realm_str, "peer-as") == 0)
+ {
+ realmid = REALM_PEER_AS;
+ }
+ else if (strcmp(realm_str, "origin-as") == 0)
+ {
+ realmid = REALM_ORIGIN_AS;
+ }
+ else
+ {
+ if (rtnl_rtrealm_a2n (&realmid, realm_str) < 0)
+ {
+ vty_out (vty, "%% Invalid realm value%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ }
+
+
+ peer = peer_and_group_lookup_vty (vty, ip_str);
+ if (! peer)
+ return CMD_WARNING;
+
+ peer_realm_set (peer, realmid);
+
+ return CMD_SUCCESS;
+}
+
+static int
+peer_realm_unset_vty (struct vty *vty, const char *ip_str)
+{
+ struct peer *peer;
+
+ peer = peer_and_group_lookup_vty (vty, ip_str);
+ if (! peer)
+ return CMD_WARNING;
+
+ peer_realm_unset (peer);
+
+ return CMD_SUCCESS;
+}
+
+DEFUN (neighbor_realm,
+ neighbor_realm_cmd,
+ NEIGHBOR_CMD2 "realm (<0-255>|WORD)",
+ NEIGHBOR_STR
+ NEIGHBOR_ADDR_STR2
+ "Set default realm for routes from this neighbor\n"
+ "default realm id\n"
+ "default realm name\n")
+{
+ return peer_realm_set_vty (vty, argv[0], argv[1]);
+}
+
+ALIAS (neighbor_realm,
+ neighbor_realm_origin_peer_cmd,
+ NEIGHBOR_CMD2 "realm (origin-as|peer-as)",
+ NEIGHBOR_STR
+ NEIGHBOR_ADDR_STR2
+ "Set default realm for routes from this neighbor\n"
+ "Set default realm to received route origin AS\n"
+ "Set default realm to peer AS")
+
+DEFUN (no_neighbor_realm,
+ no_neighbor_realm_cmd,
+ NO_NEIGHBOR_CMD2 "realm",
+ NO_STR
+ NEIGHBOR_STR
+ NEIGHBOR_ADDR_STR2
+ "Set default realm for routes from this neighbor\n")
+{
+ return peer_realm_unset_vty (vty, argv[0]);
+}
+
+ALIAS (no_neighbor_realm,
+ no_neighbor_realm_val_cmd,
+ NO_NEIGHBOR_CMD2 "realm (<0-255>|WORD)",
+ NO_STR
+ NEIGHBOR_STR
+ NEIGHBOR_ADDR_STR2
+ "Set default realm for routes from this neighbor\n"
+ "default realm id\n"
+ "default realm name\n")
+
+ALIAS (no_neighbor_realm,
+ no_neighbor_realm_origin_peer_cmd,
+ NO_NEIGHBOR_CMD2 "realm (origin-as|peer-as)",
+ NO_STR
+ NEIGHBOR_STR
+ NEIGHBOR_ADDR_STR2
+ "Set default realm for routes from this neighbor\n"
+ "Set default realm to received route origin AS\n"
+ "Set default realm to peer AS")
+#endif
+
/* Override capability negotiation. */
DEFUN (neighbor_override_capability,
neighbor_override_capability_cmd,
@@ -7429,6 +7536,27 @@ bgp_show_peer (struct vty *vty, struct peer *p)
vty_out (vty, "%s", VTY_NEWLINE);
+#ifdef SUPPORT_REALMS
+
+ /* Default realm */
+ if (CHECK_FLAG (p->config, PEER_CONFIG_REALM))
+ {
+ char realmbuf[64];
+ if (p->realm == REALM_PEER_AS)
+ vty_out (vty, " Default realm is peer-as%s",
+ VTY_NEWLINE);
+ else if (p->realm == REALM_ORIGIN_AS)
+ vty_out (vty, " Default realm is origin-as%s",
+ VTY_NEWLINE);
+ else vty_out (vty, " Default realm is %s%s",
+ rtnl_rtrealm_n2a (p->realm, realmbuf, sizeof (realmbuf)), VTY_NEWLINE);
+ }
+
+ vty_out (vty, "%s", VTY_NEWLINE);
+
+
+#endif
+
/* Address Family Information */
for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
@@ -9240,6 +9368,17 @@ bgp_vty_init (void)
install_element (BGP_NODE, &no_neighbor_weight_cmd);
install_element (BGP_NODE, &no_neighbor_weight_val_cmd);
+#ifdef SUPPORT_REALMS
+
+ /* "neighbor realm" commands. */
+ install_element (BGP_NODE, &neighbor_realm_cmd);
+ install_element (BGP_NODE, &neighbor_realm_origin_peer_cmd);
+ install_element (BGP_NODE, &no_neighbor_realm_cmd);
+ install_element (BGP_NODE, &no_neighbor_realm_origin_peer_cmd);
+ install_element (BGP_NODE, &no_neighbor_realm_val_cmd);
+
+#endif
+
/* "neighbor override-capability" commands. */
install_element (BGP_NODE, &neighbor_override_capability_cmd);
install_element (BGP_NODE, &no_neighbor_override_capability_cmd);
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index 301c15b0..1686b20e 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -723,6 +723,14 @@ bgp_zebra_announce (struct prefix *p, struct bgp_info *info, struct bgp *bgp)
api.distance = distance;
}
+#ifdef SUPPORT_REALMS
+ if (info->attr->realmto)
+ {
+ SET_FLAG (api.message, ZAPI_MESSAGE_REALMTO);
+ api.realmto = info->attr->realmto;
+ }
+#endif
+
if (BGP_DEBUG(zebra, ZEBRA))
{
char buf[2][INET_ADDRSTRLEN];
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 3f841078..7163f3f9 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -631,6 +631,10 @@ peer_global_config_reset (struct peer *peer)
peer->keepalive = 0;
peer->connect = 0;
peer->v_connect = BGP_DEFAULT_CONNECT_RETRY;
+
+#ifdef SUPPORT_REALMS
+ peer->realm = 0;
+#endif
}
/* Check peer's AS number and determin is this peer IBGP or EBGP */
@@ -791,6 +795,10 @@ peer_new (struct bgp *bgp)
peer->bgp = bgp;
peer = peer_lock (peer); /* initial reference */
+#ifdef SUPPORT_REALMS
+ peer->realm = 0;
+#endif
+
/* Set default flags. */
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
@@ -1395,6 +1403,13 @@ peer_group2peer_config_copy (struct peer_group *group, struct peer *peer,
/* Weight */
peer->weight = conf->weight;
+#ifdef CONFIG_REALMS
+
+ /* Realm */
+ peer->realm = conf->realm;
+
+#endif
+
/* peer flags apply */
peer->flags = conf->flags;
/* peer af_flags apply */
@@ -3047,7 +3062,60 @@ peer_weight_unset (struct peer *peer)
}
return 0;
}
-
+
+#ifdef SUPPORT_REALMS
+
+/* neighbor realm. */
+int
+peer_realm_set (struct peer *peer, u_int32_t realm)
+{
+ struct peer_group *group;
+ struct listnode *node, *nnode;
+
+ SET_FLAG (peer->config, PEER_CONFIG_REALM);
+ peer->realm = realm;
+
+ if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
+ return 0;
+
+ /* peer-group member updates. */
+ group = peer->group;
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
+ {
+ peer->realm = group->conf->realm;
+ }
+ return 0;
+}
+
+int
+peer_realm_unset (struct peer *peer)
+{
+ struct peer_group *group;
+ struct listnode *node, *nnode;
+
+ /* Set default realm. */
+ if (peer_group_active (peer))
+ peer->realm = peer->group->conf->realm;
+ else
+ peer->realm = 0;
+
+ UNSET_FLAG (peer->config, PEER_CONFIG_REALM);
+
+ if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
+ return 0;
+
+ /* peer-group member updates. */
+ group = peer->group;
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
+ {
+ peer->realm = 0;
+ }
+ return 0;
+}
+
+
+#endif
+
int
peer_timers_set (struct peer *peer, u_int32_t keepalive, u_int32_t holdtime)
{
@@ -4481,6 +4549,35 @@ bgp_config_write_peer (struct vty *vty, struct bgp *bgp,
vty_out (vty, " neighbor %s weight %d%s", addr, peer->weight,
VTY_NEWLINE);
+#ifdef SUPPORT_REALMS
+
+#define REALM_PEER_AS 0xFFFFA
+#define REALM_ORIGIN_AS 0xFFFFB
+
+ /* Default realm. */
+ if (CHECK_FLAG (peer->config, PEER_CONFIG_REALM))
+ if (! peer_group_active (peer) ||
+ g_peer->realm != peer->realm)
+ {
+ char realmbuf[64];
+ if (peer->realm == REALM_PEER_AS)
+ vty_out (vty, " neighbor %s realm peer-as%s", addr,
+ VTY_NEWLINE);
+ else if (peer->realm == REALM_ORIGIN_AS)
+ vty_out (vty, " neighbor %s realm origin-as%s", addr,
+ VTY_NEWLINE);
+ else vty_out (vty, " neighbor %s realm %s%s", addr,
+ rtnl_rtrealm_n2a (peer->realm, realmbuf, sizeof (realmbuf)), VTY_NEWLINE);
+ }
+#endif
+
+
+
+
+
+
+
+
/* Dynamic capability. */
if (CHECK_FLAG (peer->flags, PEER_FLAG_DYNAMIC_CAPABILITY))
if (! peer_group_active (peer) ||
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 8b180a43..e2802b9b 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -409,6 +409,11 @@ struct peer
u_int32_t connect;
u_int32_t routeadv;
+#ifdef SUPPORT_REALMS
+#define PEER_CONFIG_REALM (1 << 4) /* Default realm. */
+ u_int32_t realm;
+#endif
+
/* Timer values. */
u_int32_t v_start;
u_int32_t v_connect;
@@ -884,6 +889,11 @@ extern int peer_weight_unset (struct peer *);
extern int peer_timers_set (struct peer *, u_int32_t, u_int32_t);
extern int peer_timers_unset (struct peer *);
+#ifdef SUPPORT_REALMS
+extern int peer_realm_set (struct peer *, u_int32_t);
+extern int peer_realm_unset (struct peer *);
+#endif
+
extern int peer_timers_connect_set (struct peer *, u_int32_t);
extern int peer_timers_connect_unset (struct peer *);