[bgpd] bug #210: Enable crucial VPNv4 code which was disabled
2006-05-04 Paul Jakma <paul.jakma@sun.com>
* (general) VPNv4 fixes. Certain VPNv4 code was not enabled.
See bug #210.
* bgp_attr.{c,h}: (bgp_packet_{withdraw,attribute}) Tag should be
u_char really.
* bgp_packet.c: (bgp_{update,withdraw}_packet) Enable some
VPNv4 code which inexplicably was ifdef'd out. comments from
a tester on IRC suggest this fixes bug #210.
diff --git a/bgpd/ChangeLog b/bgpd/ChangeLog
index 2a442f2..a0ba520 100644
--- a/bgpd/ChangeLog
+++ b/bgpd/ChangeLog
@@ -1,3 +1,13 @@
+2006-05-04 Paul Jakma <paul.jakma@sun.com>
+
+ * (general) VPNv4 fixes. Certain VPNv4 code was not enabled.
+ See bug #210.
+ * bgp_attr.{c,h}: (bgp_packet_{withdraw,attribute}) Tag should be
+ u_char really.
+ * bgp_packet.c: (bgp_{update,withdraw}_packet) Enable some
+ VPNv4 code which inexplicably was ifdef'd out. comments from
+ a tester on IRC suggest this fixes bug #210.
+
2006-03-30 Paul Jakma <paul.jakma@sun.com>
* bgp_community.c: (community_gettoken) Unknown token should
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index 27ddab1..e9dde0f 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -1350,7 +1350,7 @@
bgp_packet_attribute (struct bgp *bgp, struct peer *peer,
struct stream *s, struct attr *attr, struct prefix *p,
afi_t afi, safi_t safi, struct peer *from,
- struct prefix_rd *prd, char *tag)
+ struct prefix_rd *prd, u_char *tag)
{
size_t cp;
unsigned int aspath_data_size;
@@ -1703,7 +1703,7 @@
bgp_size_t
bgp_packet_withdraw (struct peer *peer, struct stream *s, struct prefix *p,
afi_t afi, safi_t safi, struct prefix_rd *prd,
- char *tag)
+ u_char *tag)
{
unsigned long cp;
unsigned long attrlen_pnt;
diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h
index a018256..777869c 100644
--- a/bgpd/bgp_attr.h
+++ b/bgpd/bgp_attr.h
@@ -123,10 +123,10 @@
extern bgp_size_t bgp_packet_attribute (struct bgp *bgp, struct peer *,
struct stream *, struct attr *,
struct prefix *, afi_t, safi_t,
- struct peer *, struct prefix_rd *, char *);
+ struct peer *, struct prefix_rd *, u_char *);
extern bgp_size_t bgp_packet_withdraw (struct peer *peer, struct stream *s,
struct prefix *p, afi_t, safi_t,
- struct prefix_rd *, char *);
+ struct prefix_rd *, u_char *);
extern void bgp_dump_routes_attr (struct stream *, struct attr *,
struct prefix *);
extern unsigned int attrhash_key_make (struct attr *);
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index 07c3cbb..8b024a1 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -150,8 +150,6 @@
bgp_size_t total_attr_len = 0;
unsigned long pos;
char buf[BUFSIZ];
- struct prefix_rd *prd = NULL;
- char *tag = NULL;
s = peer->work;
stream_reset (s);
@@ -165,12 +163,6 @@
adj = adv->adj;
if (adv->binfo)
binfo = adv->binfo;
-#ifdef MPLS_VPN
- if (rn)
- prd = (struct prefix_rd *) &rn->prn->p;
- if (binfo)
- tag = binfo->tag;
-#endif /* MPLS_VPN */
/* When remaining space can't include NLRI and it's length. */
if (rn && STREAM_REMAIN (s) <= BGP_NLRI_LENGTH + PSIZE (rn->p.prefixlen))
@@ -179,6 +171,14 @@
/* If packet is empty, set attribute. */
if (stream_empty (s))
{
+ struct prefix_rd *prd = NULL;
+ u_char *tag = NULL;
+
+ if (rn->prn)
+ prd = (struct prefix_rd *) &rn->prn->p;
+ if (binfo)
+ tag = binfo->tag;
+
bgp_packet_set_marker (s, BGP_MSG_UPDATE);
stream_putw (s, 0);
pos = stream_get_endp (s);
@@ -282,7 +282,6 @@
bgp_size_t unfeasible_len;
bgp_size_t total_attr_len;
char buf[BUFSIZ];
- struct prefix_rd *prd = NULL;
s = peer->work;
stream_reset (s);
@@ -291,9 +290,6 @@
{
adj = adv->adj;
rn = adv->rn;
-#ifdef MPLS_VPN
- prd = (struct prefix_rd *) &rn->prn->p;
-#endif /* MPLS_VPN */
if (STREAM_REMAIN (s)
< (BGP_NLRI_LENGTH + BGP_TOTAL_ATTR_LEN + PSIZE (rn->p.prefixlen)))
@@ -309,6 +305,10 @@
stream_put_prefix (s, &rn->p);
else
{
+ struct prefix_rd *prd = NULL;
+
+ if (rn->prn)
+ prd = (struct prefix_rd *) &rn->prn->p;
pos = stream_get_endp (s);
stream_putw (s, 0);
total_attr_len