Commit cea63664 authored by Martin Mareš's avatar Martin Mareš

The `bgp_origin' attribute is now an enum.

parent a412f01e
......@@ -490,9 +490,9 @@ bgp_create_attrs(struct bgp_proto *p, rte *e, ea_list **attrs, struct linpool *p
a->flags = BAF_TRANSITIVE;
a->type = EAF_TYPE_INT;
if (rta->source == RTS_RIP_EXT || rta->source == RTS_OSPF_EXT)
a->u.data = 2; /* Incomplete */
a->u.data = ORIGIN_INCOMPLETE;
else
a->u.data = 0; /* IGP */
a->u.data = ORIGIN_IGP;
a++;
a->id = EA_CODE(EAP_BGP, BA_AS_PATH);
......@@ -638,8 +638,8 @@ bgp_rte_better(rte *new, rte *old)
/* Use origins */
x = ea_find(new->attrs->eattrs, EA_CODE(EAP_BGP, BA_ORIGIN));
y = ea_find(old->attrs->eattrs, EA_CODE(EAP_BGP, BA_ORIGIN));
n = x ? x->u.data : 2;
o = y ? y->u.data : 2;
n = x ? x->u.data : ORIGIN_INCOMPLETE;
o = y ? y->u.data : ORIGIN_INCOMPLETE;
if (n < o)
return 1;
if (n > o)
......
......@@ -167,4 +167,10 @@ void bgp_log_error(struct bgp_proto *p, char *msg, unsigned code, unsigned subco
#define BGP_COMM_NO_ADVERTISE 0xffffff02 /* Don't export at all */
#define BGP_COMM_NO_EXPORT_SUBCONFED 0xffffff03 /* NO_EXPORT even in local confederation */
/* Origins */
#define ORIGIN_IGP 0
#define ORIGIN_EGP 1
#define ORIGIN_INCOMPLETE 2
#endif
......@@ -10,6 +10,8 @@ CF_HDR
#include "proto/bgp/bgp.h"
CF_DEFINES
#define BGP_CFG ((struct bgp_config *) this_proto)
CF_DECLS
......@@ -74,7 +76,7 @@ CF_ADDTO(dynamic_attr, BGP_LOCAL_PREF
CF_ADDTO(dynamic_attr, BGP_MED
{ $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_CODE(EAP_BGP, BA_MULTI_EXIT_DISC)); })
CF_ADDTO(dynamic_attr, BGP_ORIGIN
{ $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_CODE(EAP_BGP, BA_ORIGIN)); })
{ $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_ENUM_BGP_ORIGIN, EA_CODE(EAP_BGP, BA_ORIGIN)); })
CF_ADDTO(dynamic_attr, BGP_NEXT_HOP
{ $$ = f_new_dynamic_attr(EAF_TYPE_IP_ADDRESS, T_IP, EA_CODE(EAP_BGP, BA_NEXT_HOP)); })
CF_ADDTO(dynamic_attr, BGP_ATOMIC_AGGR
......@@ -84,6 +86,8 @@ CF_ADDTO(dynamic_attr, BGP_AGGREGATOR
CF_ADDTO(dynamic_attr, BGP_COMMUNITY
{ $$ = f_new_dynamic_attr(EAF_TYPE_INT_SET, T_CLIST, EA_CODE(EAP_BGP, BA_COMMUNITY)); })
CF_ENUM(T_ENUM_BGP_ORIGIN, ORIGIN_, IGP, EGP, INCOMPLETE)
CF_CODE
CF_END
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment