summaryrefslogtreecommitdiff
path: root/bgpd
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/ChangeLog9
-rw-r--r--bgpd/bgp_debug.c39
-rw-r--r--bgpd/bgp_debug.h2
-rw-r--r--bgpd/bgp_packet.c67
4 files changed, 96 insertions, 21 deletions
diff --git a/bgpd/ChangeLog b/bgpd/ChangeLog
index 0e81fc08..0aac403f 100644
--- a/bgpd/ChangeLog
+++ b/bgpd/ChangeLog
@@ -1,3 +1,12 @@
+2004-07-09 Paul Jakma <paul@dishone.st>
+
+ * Merge of GNU Zebra cvs2svn changesets r799, r800 and r807.
+ * bgp_dump.c: (bgp_dump_attr) cleanup. return status code. check
+ attributes present before printing.
+ * bgp_dump.c: update bgp_dump_attr prototype.
+ * bgp_packet.c: (bgp_update_receive) init attrstr. check status
+ of bgp_dump_attr. Log end-of-rib UPDATEs.
+
2004-07-09 Sowmini Varadhan <sowmini.varadhan@sun.com>
* bgp_packet.c: (bgp_collision_detect) Send NOTIFY on new socket
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c
index 8141c8b9..9c5208da 100644
--- a/bgpd/bgp_debug.c
+++ b/bgpd/bgp_debug.c
@@ -158,16 +158,18 @@ char *bgp_origin_str[] = {"i","e","?"};
char *bgp_origin_long_str[] = {"IGP","EGP","incomplete"};
/* Dump attribute. */
-void
+int
bgp_dump_attr (struct peer *peer, struct attr *attr, char *buf, size_t size)
{
-
if (! attr)
- return;
+ return 0;
- snprintf (buf, size, "nexthop %s", inet_ntoa (attr->nexthop));
- snprintf (buf + strlen (buf), size - strlen (buf), ", origin %s",
- bgp_origin_str[attr->origin]);
+ if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP)))
+ snprintf (buf, size, "nexthop %s", inet_ntoa (attr->nexthop));
+
+ if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ORIGIN)))
+ snprintf (buf + strlen (buf), size - strlen (buf), ", origin %s",
+ bgp_origin_str[attr->origin]);
#ifdef HAVE_IPV6
{
@@ -186,42 +188,47 @@ bgp_dump_attr (struct peer *peer, struct attr *attr, char *buf, size_t size)
}
#endif /* HAVE_IPV6 */
- if (peer_sort (peer) == BGP_PEER_IBGP)
+ if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))
snprintf (buf + strlen (buf), size - strlen (buf), ", localpref %d",
attr->local_pref);
- if (attr->med)
+ if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)))
snprintf (buf + strlen (buf), size - strlen (buf), ", metric %d",
attr->med);
- if (attr->community)
+ if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES)))
snprintf (buf + strlen (buf), size - strlen (buf), ", community %s",
community_str (attr->community));
- if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
+ if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))
snprintf (buf + strlen (buf), size - strlen (buf), ", atomic-aggregate");
- if (attr->aggregator_as)
+ if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
snprintf (buf + strlen (buf), size - strlen (buf), ", aggregated by %d %s",
attr->aggregator_as, inet_ntoa (attr->aggregator_addr));
- if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))
+ if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)))
snprintf (buf + strlen (buf), size - strlen (buf), ", originator %s",
inet_ntoa (attr->originator_id));
- if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST))
+ if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST)))
{
int i;
- snprintf (buf + strlen (buf), size - strlen (buf), ", clusterlist ");
+ snprintf (buf + strlen (buf), size - strlen (buf), ", clusterlist");
for (i = 0; i < attr->cluster->length / 4; i++)
- snprintf (buf + strlen (buf), size - strlen (buf), "%s",
+ snprintf (buf + strlen (buf), size - strlen (buf), " %s",
inet_ntoa (attr->cluster->list[i]));
}
- if (attr->aspath)
+ if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH)))
snprintf (buf + strlen (buf), size - strlen (buf), ", path %s",
aspath_print (attr->aspath));
+
+ if (strlen (buf) > 1)
+ return 1;
+ else
+ return 0;
}
/* dump notify packet */
diff --git a/bgpd/bgp_debug.h b/bgpd/bgp_debug.h
index 06ba0757..14a8c5fe 100644
--- a/bgpd/bgp_debug.h
+++ b/bgpd/bgp_debug.h
@@ -106,7 +106,7 @@ extern unsigned long term_bgp_debug_normal;
extern char *bgp_type_str[];
-void bgp_dump_attr (struct peer *, struct attr *, char *, size_t);
+int bgp_dump_attr (struct peer *, struct attr *, char *, size_t);
void bgp_notify_print (struct peer *, struct bgp_notify *, char *);
extern struct message bgp_status_msg[];
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index 37f5afdc..42820273 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -1375,7 +1375,7 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
struct bgp_nlri withdraw;
struct bgp_nlri mp_update;
struct bgp_nlri mp_withdraw;
- char attrstr[BUFSIZ];
+ char attrstr[BUFSIZ] = "";
/* Status must be Established. */
if (peer->status != Established)
@@ -1478,9 +1478,11 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
/* Logging the attribute. */
if (BGP_DEBUG (update, UPDATE_IN))
{
- bgp_dump_attr (peer, &attr, attrstr, BUFSIZ);
- zlog (peer->log, LOG_INFO, "%s rcvd UPDATE w/ attr: %s",
- peer->host, attrstr);
+ ret= bgp_dump_attr (peer, &attr, attrstr, BUFSIZ);
+
+ if (ret)
+ zlog (peer->log, LOG_INFO, "%s rcvd UPDATE w/ attr: %s",
+ peer->host, attrstr);
}
/* Network Layer Reachability Information. */
@@ -1518,6 +1520,15 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
bgp_nlri_parse (peer, &attr, &update);
}
+
+ if (! attribute_len && ! withdraw_len)
+ {
+ /* End-of-RIB received */
+
+ if (BGP_DEBUG (update, UPDATE_IN))
+ zlog (peer->log, LOG_INFO, "rcvd End-of-RIB for IPv4 Unicast from %s",
+ peer->host);
+ }
}
if (peer->afc[AFI_IP][SAFI_MULTICAST])
{
@@ -1530,6 +1541,18 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
&& mp_withdraw.afi == AFI_IP
&& mp_withdraw.safi == SAFI_MULTICAST)
bgp_nlri_parse (peer, NULL, &mp_withdraw);
+
+ if (attribute_len == 6 && ! withdraw_len
+ && mp_withdraw.afi == AFI_IP
+ && mp_withdraw.safi == SAFI_MULTICAST
+ && mp_withdraw.length == 0)
+ {
+ /* End-of-RIB received */
+
+ if (BGP_DEBUG (update, UPDATE_IN))
+ zlog (peer->log, LOG_INFO, "rcvd End-of-RIB for IPv4 Multicast from %s",
+ peer->host);
+ }
}
if (peer->afc[AFI_IP6][SAFI_UNICAST])
{
@@ -1542,6 +1565,18 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
&& mp_withdraw.afi == AFI_IP6
&& mp_withdraw.safi == SAFI_UNICAST)
bgp_nlri_parse (peer, NULL, &mp_withdraw);
+
+ if (attribute_len == 6 && ! withdraw_len
+ && mp_withdraw.afi == AFI_IP6
+ && mp_withdraw.safi == SAFI_UNICAST
+ && mp_withdraw.length == 0)
+ {
+ /* End-of-RIB received */
+
+ if (BGP_DEBUG (update, UPDATE_IN))
+ zlog (peer->log, LOG_INFO, "rcvd End-of-RIB for IPv6 Unicast from %s",
+ peer->host);
+ }
}
if (peer->afc[AFI_IP6][SAFI_MULTICAST])
{
@@ -1554,6 +1589,18 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
&& mp_withdraw.afi == AFI_IP6
&& mp_withdraw.safi == SAFI_MULTICAST)
bgp_nlri_parse (peer, NULL, &mp_withdraw);
+
+ if (attribute_len == 6 && ! withdraw_len
+ && mp_withdraw.afi == AFI_IP6
+ && mp_withdraw.safi == SAFI_MULTICAST
+ && mp_withdraw.length == 0)
+ {
+ /* End-of-RIB received */
+
+ if (BGP_DEBUG (update, UPDATE_IN))
+ zlog (peer->log, LOG_INFO, "rcvd End-of-RIB for IPv6 Multicast from %s",
+ peer->host);
+ }
}
if (peer->afc[AFI_IP][SAFI_MPLS_VPN])
{
@@ -1566,6 +1613,18 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
&& mp_withdraw.afi == AFI_IP
&& mp_withdraw.safi == BGP_SAFI_VPNV4)
bgp_nlri_parse_vpnv4 (peer, NULL, &mp_withdraw);
+
+ if (attribute_len == 6 && ! withdraw_len
+ && mp_withdraw.afi == AFI_IP
+ && mp_withdraw.safi == BGP_SAFI_VPNV4
+ && mp_withdraw.length == 0)
+ {
+ /* End-of-RIB received */
+
+ if (BGP_DEBUG (update, UPDATE_IN))
+ zlog (peer->log, LOG_INFO, "rcvd End-of-RIB for VPNv4 Unicast from %s",
+ peer->host);
+ }
}
/* Everything is done. We unintern temporary structures which