* lib/zebra.h: Introduce a route_tag_t type for route tags generally,
and make it 4 bytes wide - so it can directly hold things like an ASN, or
the OSPF ASE-LSA tag.
* zebra/rib.h: Use route_tag_t instead of u_short.
* *: Update 'u_short (*)?(tag|tmp)' to use route_tag_t instead of u_short.
Update stream_{get,put} to l instead of w.
* ospf_zebra.c: (ospf_zebra_add) test OSPF tag within range of ROUTE_TAG_MAX.
---
bgpd/bgp_attr.h | 2 +-
bgpd/bgp_route.c | 2 +-
bgpd/bgp_route.h | 2 +-
bgpd/bgp_routemap.c | 12 ++++++------
bgpd/bgp_zebra.c | 6 +++---
lib/zclient.c | 4 ++--
lib/zclient.h | 4 ++--
lib/zebra.h | 3 +++
ospfd/ospf_asbr.c | 2 +-
ospfd/ospf_asbr.h | 2 +-
ospfd/ospf_lsa.c | 2 +-
ospfd/ospf_routemap.c | 12 ++++++------
ospfd/ospf_zebra.c | 8 ++++----
ospfd/ospfd.h | 2 +-
ripd/rip_routemap.c | 10 +++++-----
zebra/rib.h | 23 +++++++++++++----------
zebra/zebra_rib.c | 12 +++++++-----
zebra/zebra_vty.c | 8 ++++----
zebra/zserv.c | 10 +++++-----
19 files changed, 67 insertions(+), 59 deletions(-)
diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h
index 6e680cc..522d6f5 100644
--- a/bgpd/bgp_attr.h
+++ b/bgpd/bgp_attr.h
@@ -94,7 +94,7 @@ struct attr_extra
struct bgp_attr_encap_subtlv *encap_subtlvs; /* rfc5512 */
/* route tag */
- u_short tag;
+ route_tag_t tag;
};
/* BGP core attribute structure. */
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 65c8180..8b501f3 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -5956,7 +5956,7 @@ ALIAS (no_ipv6_aggregate_address_summary_only,
void
bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop,
const struct in6_addr *nexthop6, ifindex_t ifindex,
- u_int32_t metric, u_char type, u_short tag)
+ u_int32_t metric, u_char type, route_tag_t tag)
{
struct bgp *bgp;
struct listnode *node, *nnode;
diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h
index fd12d09..0787ef2 100644
--- a/bgpd/bgp_route.h
+++ b/bgpd/bgp_route.h
@@ -227,7 +227,7 @@ extern int bgp_maximum_prefix_overflow (struct peer *,
afi_t, safi_t, int);
extern void bgp_redistribute_add (struct prefix *, const struct in_addr *,
const struct in6_addr *,
ifindex_t,
- u_int32_t, u_char, u_short);
+ u_int32_t, u_char, route_tag_t);
extern void bgp_redistribute_delete (struct prefix *, u_char);
extern void bgp_redistribute_withdraw (struct bgp *, afi_t, int);
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index 6664def..e7c09a3 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -1063,7 +1063,7 @@ static route_map_result_t
route_match_tag (void *rule, struct prefix *prefix,
route_map_object_t type, void *object)
{
- u_short *tag;
+ route_tag_t *tag;
struct bgp_info *bgp_info;
if (type == RMAP_BGP)
@@ -1085,8 +1085,8 @@ route_match_tag (void *rule, struct prefix *prefix,
static void *
route_match_tag_compile (const char *arg)
{
- u_short *tag;
- u_short tmp;
+ route_tag_t *tag;
+ route_tag_t tmp;
/* tag value shoud be integer. */
if (! all_digit (arg))
@@ -1902,7 +1902,7 @@ static route_map_result_t
route_set_tag (void *rule, struct prefix *prefix,
route_map_object_t type, void *object)
{
- u_short *tag;
+ route_tag_t *tag;
struct bgp_info *bgp_info;
struct attr_extra *ae;
@@ -1924,8 +1924,8 @@ route_set_tag (void *rule, struct prefix *prefix,
static void *
route_set_tag_compile (const char *arg)
{
- u_short *tag;
- u_short tmp;
+ route_tag_t *tag;
+ route_tag_t tmp;
/* tag value shoud be integer. */
if (! all_digit (arg))
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index dbbfd6d..00adebc 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -421,7 +421,7 @@ zebra_read_ipv4 (int command, struct zclient *zclient,
zebra_size_t length,
api.metric = 0;
if (CHECK_FLAG (api.message, ZAPI_MESSAGE_TAG))
- api.tag = stream_getw (s);
+ api.tag = stream_getl (s);
else
api.tag = 0;
@@ -513,7 +513,7 @@ zebra_read_ipv6 (int command, struct zclient *zclient,
zebra_size_t length,
api.metric = 0;
if (CHECK_FLAG (api.message, ZAPI_MESSAGE_TAG))
- api.tag = stream_getw (s);
+ api.tag = stream_getl (s);
else
api.tag = 0;
@@ -900,7 +900,7 @@ bgp_zebra_announce (struct prefix *p, struct bgp_info
*info, struct bgp *bgp,
u_int32_t nhcount, metric;
struct bgp_info local_info;
struct bgp_info *info_cp = &local_info;
- u_short tag = 0;
+ route_tag_t tag = 0;
if (zclient->sock < 0)
return;
diff --git a/lib/zclient.c b/lib/zclient.c
index d89a5c0..c3be1ab 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -591,7 +591,7 @@ zapi_ipv4_route (u_char cmd, struct zclient *zclient,
struct prefix_ipv4 *p,
if (CHECK_FLAG (api->message, ZAPI_MESSAGE_MTU))
stream_putl (s, api->mtu);
if (CHECK_FLAG (api->message, ZAPI_MESSAGE_TAG))
- stream_putw (s, api->tag);
+ stream_putl (s, api->tag);
/* Put length at the first point of the stream. */
stream_putw_at (s, 0, stream_get_endp (s));
@@ -657,7 +657,7 @@ zapi_ipv6_route (u_char cmd, struct zclient *zclient,
struct prefix_ipv6 *p,
if (CHECK_FLAG (api->message, ZAPI_MESSAGE_MTU))
stream_putl (s, api->mtu);
if (CHECK_FLAG (api->message, ZAPI_MESSAGE_TAG))
- stream_putw (s, api->tag);
+ stream_putl (s, api->tag);
/* Put length at the first point of the stream. */
stream_putw_at (s, 0, stream_get_endp (s));
diff --git a/lib/zclient.h b/lib/zclient.h
index 191f0d2..728adce 100644
--- a/lib/zclient.h
+++ b/lib/zclient.h
@@ -136,7 +136,7 @@ struct zapi_ipv4
u_char distance;
- u_short tag;
+ route_tag_t tag;
u_int32_t metric;
@@ -228,7 +228,7 @@ struct zapi_ipv6
u_char distance;
- u_short tag;
+ route_tag_t tag;
u_int32_t metric;
diff --git a/lib/zebra.h b/lib/zebra.h
index a53595b..e91dcea 100644
--- a/lib/zebra.h
+++ b/lib/zebra.h
@@ -538,4 +538,7 @@ typedef u_int16_t zebra_command_t;
/* VRF ID type. */
typedef u_int16_t vrf_id_t;
+typedef uint32_t route_tag_t;
+#define ROUTE_TAG_MAX UINT32_MAX
+
#endif /* _ZEBRA_H */
diff --git a/ospfd/ospf_asbr.c b/ospfd/ospf_asbr.c
index 4b53690..0a411e4 100644
--- a/ospfd/ospf_asbr.c
+++ b/ospfd/ospf_asbr.c
@@ -136,7 +136,7 @@ ospf_route_map_set_compare (struct route_map_set_values
*values1,
struct external_info *
ospf_external_info_add (u_char type, struct prefix_ipv4 p,
ifindex_t ifindex, struct in_addr nexthop,
- u_short tag)
+ route_tag_t tag)
{
struct external_info *new;
struct route_node *rn;
diff --git a/ospfd/ospf_asbr.h b/ospfd/ospf_asbr.h
index 2709a6c..bc41a14 100644
--- a/ospfd/ospf_asbr.h
+++ b/ospfd/ospf_asbr.h
@@ -63,7 +63,7 @@ extern struct external_info *ospf_external_info_add (u_char,
struct prefix_ipv4,
ifindex_t,
struct in_addr,
- u_short);
+ route_tag_t);
extern void ospf_external_info_delete (u_char, struct prefix_ipv4);
extern struct external_info *ospf_external_info_lookup (u_char,
struct prefix_ipv4 *);
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index adc0265..a1a14ab 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -1664,7 +1664,7 @@ ospf_external_lsa_body_set (struct stream *s, struct
external_info *ei,
/* Put forwarding address. */
stream_put_ipv4 (s, fwd_addr.s_addr);
- /* Put route tag -- only first 16bits are used for compatibility */
+ /* Put route tag */
stream_putl (s, ei->tag);
}
diff --git a/ospfd/ospf_routemap.c b/ospfd/ospf_routemap.c
index 133b1e3..dc41812 100644
--- a/ospfd/ospf_routemap.c
+++ b/ospfd/ospf_routemap.c
@@ -422,7 +422,7 @@ static route_map_result_t
route_match_tag (void *rule, struct prefix *prefix,
route_map_object_t type, void *object)
{
- u_short *tag;
+ route_tag_t *tag;
struct external_info *ei;
if (type == RMAP_OSPF)
@@ -440,8 +440,8 @@ route_match_tag (void *rule, struct prefix *prefix,
static void *
route_match_tag_compile (const char *arg)
{
- u_short *tag;
- u_short tmp;
+ route_tag_t *tag;
+ route_tag_t tmp;
/* tag value shoud be integer. */
if (! all_digit (arg))
@@ -611,7 +611,7 @@ static route_map_result_t
route_set_tag (void *rule, struct prefix *prefix,
route_map_object_t type, void *object)
{
- u_short *tag;
+ route_tag_t *tag;
struct external_info *ei;
if (type == RMAP_OSPF)
@@ -630,8 +630,8 @@ route_set_tag (void *rule, struct prefix *prefix,
static void *
route_set_tag_compile (const char *arg)
{
- u_short *tag;
- u_short tmp;
+ route_tag_t *tag;
+ route_tag_t tmp;
/* tag value shoud be integer. */
if (! all_digit (arg))
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index 2786ca3..d7470f7 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -370,10 +370,10 @@ ospf_zebra_add (struct prefix_ipv4 *p, struct ospf_route
*or)
if (distance)
SET_FLAG (message, ZAPI_MESSAGE_DISTANCE);
- /* Check if path type is ASE and use only 16bit tags */
+ /* Check if path type is ASE */
if (((or->path_type == OSPF_PATH_TYPE1_EXTERNAL) ||
(or->path_type == OSPF_PATH_TYPE2_EXTERNAL)) &&
- (or->u.ext.tag > 0) && (or->u.ext.tag < UINT16_MAX))
+ (or->u.ext.tag > 0) && (or->u.ext.tag <= ROUTE_TAG_MAX))
SET_FLAG (message, ZAPI_MESSAGE_TAG);
/* Make packet. */
@@ -445,7 +445,7 @@ ospf_zebra_add (struct prefix_ipv4 *p, struct ospf_route
*or)
}
if (CHECK_FLAG (message, ZAPI_MESSAGE_TAG))
- stream_putw (s, (u_short)or->u.ext.tag);
+ stream_putl (s, or->u.ext.tag);
stream_putw_at (s, 0, stream_get_endp (s));
@@ -901,7 +901,7 @@ ospf_zebra_read_ipv4 (int command, struct zclient *zclient,
if (CHECK_FLAG (api.message, ZAPI_MESSAGE_METRIC))
api.metric = stream_getl (s);
if (CHECK_FLAG (api.message, ZAPI_MESSAGE_TAG))
- api.tag = stream_getw (s);
+ api.tag = stream_getl (s);
else
api.tag = 0;
diff --git a/ospfd/ospfd.h b/ospfd/ospfd.h
index 92e49b8..4c1e350 100644
--- a/ospfd/ospfd.h
+++ b/ospfd/ospfd.h
@@ -241,7 +241,7 @@ struct ospf
} dmetric [ZEBRA_ROUTE_MAX + 1];
/* Redistribute tag info. */
- u_short dtag [ZEBRA_ROUTE_MAX + 1];
+ route_tag_t dtag [ZEBRA_ROUTE_MAX + 1];
/* For redistribute route map. */
struct
diff --git a/ripd/rip_routemap.c b/ripd/rip_routemap.c
index e04e43d..20d3e6e 100644
--- a/ripd/rip_routemap.c
+++ b/ripd/rip_routemap.c
@@ -463,7 +463,7 @@ static route_map_result_t
route_match_tag (void *rule, struct prefix *prefix,
route_map_object_t type, void *object)
{
- u_short *tag;
+ route_tag_t *tag;
struct rip_info *rinfo;
if (type == RMAP_RIP)
@@ -484,8 +484,8 @@ route_match_tag (void *rule, struct prefix *prefix,
static void *
route_match_tag_compile (const char *arg)
{
- u_short *tag;
- u_short tmp;
+ route_tag_t *tag;
+ route_tag_t tmp;
/* tag value shoud be integer. */
if (! all_digit (arg))
@@ -687,7 +687,7 @@ static route_map_result_t
route_set_tag (void *rule, struct prefix *prefix,
route_map_object_t type, void *object)
{
- u_short *tag;
+ route_tag_t *tag;
struct rip_info *rinfo;
if(type == RMAP_RIP)
@@ -708,7 +708,7 @@ route_set_tag (void *rule, struct prefix *prefix,
static void *
route_set_tag_compile (const char *arg)
{
- u_short *tag;
+ route_tag_t *tag;
tag = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_short));
*tag = atoi (arg);
diff --git a/zebra/rib.h b/zebra/rib.h
index 00c7150..b1fc090 100644
--- a/zebra/rib.h
+++ b/zebra/rib.h
@@ -23,6 +23,7 @@
#ifndef _ZEBRA_RIB_H
#define _ZEBRA_RIB_H
+#include "zebra.h"
#include "linklist.h"
#include "prefix.h"
#include "table.h"
@@ -43,6 +44,9 @@ struct rib
/* Refrence count. */
unsigned long refcnt;
+ /* Tag */
+ route_tag_t tag;
+
/* Uptime. */
time_t uptime;
@@ -65,9 +69,6 @@ struct rib
/* Distance. */
u_char distance;
- /* Tag */
- u_short tag;
-
/* Flags of this route.
* This flag's definition is in lib/zebra.h ZEBRA_FLAG_* and is exposed
* to clients via Zserv
@@ -183,7 +184,7 @@ struct static_route
u_char distance;
/* Tag */
- u_short tag;
+ route_tag_t tag;
/* Flag for this static route's type. */
u_char type;
@@ -446,11 +447,12 @@ extern void rib_queue_add (struct zebra_t *zebra, struct
route_node *rn);
extern int
static_add_ipv4_safi (safi_t safi, struct prefix *p, struct in_addr *gate,
- const char *ifname, u_char flags, u_short tag, u_char
distance,
- vrf_id_t vrf_id);
+ const char *ifname, u_char flags, route_tag_t,
+ u_char distance, vrf_id_t vrf_id);
extern int
static_delete_ipv4_safi (safi_t safi, struct prefix *p, struct in_addr *gate,
- const char *ifname, u_short tag, u_char distance,
vrf_id_t vrf_id);
+ const char *ifname, route_tag_t tag, u_char distance,
+ vrf_id_t vrf_id);
extern int
rib_add_ipv6 (int type, int flags, struct prefix_ipv6 *p,
@@ -470,15 +472,16 @@ extern struct route_table *rib_table_ipv6;
extern int
static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
- const char *ifname, u_char flags, u_short tag, u_char distance,
- vrf_id_t vrf_id);
+ const char *ifname, u_char flags, route_tag_t,
+ u_char distance, vrf_id_t vrf_id);
extern int
rib_add_ipv6_multipath (struct prefix_ipv6 *, struct rib *, safi_t);
extern int
static_delete_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
- const char *ifname, u_short tag, u_char distance, vrf_id_t
vrf_id);
+ const char *ifname, route_tag_t, u_char distance,
+ vrf_id_t vrf_id);
extern int rib_gc_dest (struct route_node *rn);
extern struct route_table *rib_tables_iter_next (rib_tables_iter_t *iter);
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 3566f15..0aa9f56 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -2526,8 +2526,8 @@ static_uninstall_route (afi_t afi, safi_t safi, struct
prefix *p, struct static_
int
static_add_ipv4_safi (safi_t safi, struct prefix *p, struct in_addr *gate,
- const char *ifname, u_char flags, u_short tag, u_char
distance,
- vrf_id_t vrf_id)
+ const char *ifname, u_char flags, route_tag_t tag,
+ u_char distance, vrf_id_t vrf_id)
{
u_char type = 0;
struct route_node *rn;
@@ -2623,7 +2623,8 @@ static_add_ipv4_safi (safi_t safi, struct prefix *p,
struct in_addr *gate,
int
static_delete_ipv4_safi (safi_t safi, struct prefix *p, struct in_addr *gate,
- const char *ifname, u_short tag, u_char distance,
vrf_id_t vrf_id)
+ const char *ifname, route_tag_t tag, u_char distance,
+ vrf_id_t vrf_id)
{
u_char type = 0;
struct route_node *rn;
@@ -3009,7 +3010,7 @@ rib_delete_ipv6 (int type, int flags, struct prefix_ipv6
*p,
/* Add static route into static route configuration. */
int
static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
- const char *ifname, u_char flags, u_short tag,
+ const char *ifname, u_char flags, route_tag_t tag,
u_char distance, vrf_id_t vrf_id)
{
struct route_node *rn;
@@ -3107,7 +3108,8 @@ static_add_ipv6 (struct prefix *p, u_char type, struct
in6_addr *gate,
/* Delete static route from static route configuration. */
int
static_delete_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
- const char *ifname, u_short tag, u_char distance, vrf_id_t
vrf_id)
+ const char *ifname, route_tag_t tag, u_char distance,
+ vrf_id_t vrf_id)
{
struct route_node *rn;
struct static_route *si;
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index be8a583..b42e7d8 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -54,7 +54,7 @@ zebra_static_ipv4_safi (struct vty *vty, safi_t safi, int
add_cmd,
struct in_addr mask;
const char *ifname;
u_char flag = 0;
- u_short tag = 0;
+ route_tag_t tag = 0;
vrf_id_t vrf_id = VRF_DEFAULT;
ret = str2prefix (dest_str, &p);
@@ -2400,7 +2400,7 @@ DEFUN (show_ip_route_tag,
struct route_node *rn;
struct rib *rib;
int first = 1;
- u_short tag = 0;
+ route_tag_t tag = 0;
vrf_id_t vrf_id = VRF_DEFAULT;
if (argv[0])
@@ -3306,7 +3306,7 @@ static_ipv6_func (struct vty *vty, int add_cmd, const
char *dest_str,
u_char type = 0;
vrf_id_t vrf_id = VRF_DEFAULT;
u_char flag = 0;
- u_short tag = 0;
+ route_tag_t tag = 0;
ret = str2prefix (dest_str, &p);
if (ret <= 0)
@@ -4416,7 +4416,7 @@ DEFUN (show_ipv6_route_tag,
struct route_node *rn;
struct rib *rib;
int first = 1;
- u_short tag = 0;
+ route_tag_t tag = 0;
vrf_id_t vrf_id = VRF_DEFAULT;
if (argv[0])
diff --git a/zebra/zserv.c b/zebra/zserv.c
index 1815901..1047ec0 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -650,7 +650,7 @@ zsend_route_multipath (int cmd, struct zserv *client,
struct prefix *p,
if (rib->tag)
{
SET_FLAG(zapi_flags, ZAPI_MESSAGE_TAG);
- stream_putw(s, rib->tag);
+ stream_putl (s, rib->tag);
}
}
@@ -1231,7 +1231,7 @@ zread_ipv4_add (struct zserv *client, u_short length,
vrf_id_t vrf_id)
rib->mtu = stream_getl (s);
/* Tag */
if (CHECK_FLAG (message, ZAPI_MESSAGE_TAG))
- rib->tag = stream_getw (s);
+ rib->tag = stream_getl (s);
/* Table */
rib->table=zebrad.rtm_table_default;
@@ -1324,7 +1324,7 @@ zread_ipv4_delete (struct zserv *client, u_short length,
vrf_id_t vrf_id)
/* tag */
if (CHECK_FLAG (api.message, ZAPI_MESSAGE_TAG))
- api.tag = stream_getw (s);
+ api.tag = stream_getl (s);
else
api.tag = 0;
@@ -1482,7 +1482,7 @@ zread_ipv6_add (struct zserv *client, u_short length,
vrf_id_t vrf_id)
/* Tag */
if (CHECK_FLAG (message, ZAPI_MESSAGE_TAG))
- rib->tag = stream_getw (s);
+ rib->tag = stream_getl (s);
/* Table */
rib->table=zebrad.rtm_table_default;
@@ -1559,7 +1559,7 @@ zread_ipv6_delete (struct zserv *client, u_short length,
vrf_id_t vrf_id)
/* tag */
if (CHECK_FLAG (api.message, ZAPI_MESSAGE_TAG))
- api.tag = stream_getw (s);
+ api.tag = stream_getl (s);
else
api.tag = 0;
--
2.5.5
_______________________________________________
Quagga-dev mailing list
[email protected]
https://lists.quagga.net/mailman/listinfo/quagga-dev