From: Donald Sharp Date: Sun, 22 Mar 2020 01:56:36 +0000 (-0400) Subject: bgpd: Rework code to use `const struct prefix` X-Git-Tag: base_7.4~176^2~1 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=5a1ae2c237777c6a5a909b89b302cb9c70825092;p=matthieu%2Ffrr.git bgpd: Rework code to use `const struct prefix` Future work needs the ability to specify a const struct prefix value. Iterate into bgp a bit to get this started. Signed-off-by: Donald Sharp --- diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 5972359f73..5202f6801e 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -3524,7 +3524,7 @@ static int install_uninstall_route_in_vnis(struct bgp *bgp, afi_t afi, * Install or uninstall route for appropriate VNIs/ESIs. */ static int install_uninstall_evpn_route(struct bgp *bgp, afi_t afi, safi_t safi, - struct prefix *p, + const struct prefix *p, struct bgp_path_info *pi, int import) { struct prefix_evpn *evp = (struct prefix_evpn *)p; @@ -5550,7 +5550,7 @@ void bgp_evpn_es_free(struct bgp *bgp, struct evpnes *es) * Import evpn route from global table to VNI/VRF/ESI. */ int bgp_evpn_import_route(struct bgp *bgp, afi_t afi, safi_t safi, - struct prefix *p, struct bgp_path_info *pi) + const struct prefix *p, struct bgp_path_info *pi) { return install_uninstall_evpn_route(bgp, afi, safi, p, pi, 1); } @@ -5559,7 +5559,7 @@ int bgp_evpn_import_route(struct bgp *bgp, afi_t afi, safi_t safi, * Unimport evpn route from VNI/VRF/ESI. */ int bgp_evpn_unimport_route(struct bgp *bgp, afi_t afi, safi_t safi, - struct prefix *p, struct bgp_path_info *pi) + const struct prefix *p, struct bgp_path_info *pi) { return install_uninstall_evpn_route(bgp, afi, safi, p, pi, 0); } @@ -6280,7 +6280,7 @@ int bgp_evpn_get_type5_prefixlen(struct prefix *pfx) /* * Should we register nexthop for this EVPN prefix for nexthop tracking? */ -bool bgp_evpn_is_prefix_nht_supported(struct prefix *pfx) +bool bgp_evpn_is_prefix_nht_supported(const struct prefix *pfx) { struct prefix_evpn *evp = (struct prefix_evpn *)pfx; diff --git a/bgpd/bgp_evpn.h b/bgpd/bgp_evpn.h index 308ced098f..219321fc68 100644 --- a/bgpd/bgp_evpn.h +++ b/bgpd/bgp_evpn.h @@ -164,9 +164,11 @@ extern void bgp_evpn_encode_prefix(struct stream *s, struct prefix *p, extern int bgp_nlri_parse_evpn(struct peer *peer, struct attr *attr, struct bgp_nlri *packet, int withdraw); extern int bgp_evpn_import_route(struct bgp *bgp, afi_t afi, safi_t safi, - struct prefix *p, struct bgp_path_info *ri); + const struct prefix *p, + struct bgp_path_info *ri); extern int bgp_evpn_unimport_route(struct bgp *bgp, afi_t afi, safi_t safi, - struct prefix *p, struct bgp_path_info *ri); + const struct prefix *p, + struct bgp_path_info *ri); extern int bgp_filter_evpn_routes_upon_martian_nh_change(struct bgp *bgp); extern int bgp_evpn_local_macip_del(struct bgp *bgp, vni_t vni, struct ethaddr *mac, struct ipaddr *ip, @@ -194,7 +196,7 @@ extern void bgp_evpn_cleanup_on_disable(struct bgp *bgp); extern void bgp_evpn_cleanup(struct bgp *bgp); extern void bgp_evpn_init(struct bgp *bgp); extern int bgp_evpn_get_type5_prefixlen(struct prefix *pfx); -extern bool bgp_evpn_is_prefix_nht_supported(struct prefix *pfx); +extern bool bgp_evpn_is_prefix_nht_supported(const struct prefix *pfx); extern void update_advertise_vrf_routes(struct bgp *bgp_vrf); #endif /* _QUAGGA_BGP_EVPN_H */ diff --git a/bgpd/bgp_mac.c b/bgpd/bgp_mac.c index 537bb45455..fed88fd508 100644 --- a/bgpd/bgp_mac.c +++ b/bgpd/bgp_mac.c @@ -358,7 +358,7 @@ void bgp_mac_del_mac_entry(struct interface *ifp) * An example: router-mac attribute in any of evpn update * requires to compare against local mac. */ -bool bgp_mac_exist(struct ethaddr *mac) +bool bgp_mac_exist(const struct ethaddr *mac) { struct bgp_self_mac lookup; struct bgp_self_mac *bsm; @@ -379,9 +379,9 @@ bool bgp_mac_exist(struct ethaddr *mac) * mac against any of local assigned (SVIs) MAC * address. */ -bool bgp_mac_entry_exists(struct prefix *p) +bool bgp_mac_entry_exists(const struct prefix *p) { - struct prefix_evpn *pevpn = (struct prefix_evpn *)p; + const struct prefix_evpn *pevpn = (const struct prefix_evpn *)p; if (pevpn->family != AF_EVPN) return false; diff --git a/bgpd/bgp_mac.h b/bgpd/bgp_mac.h index 68449b574a..4b94d80d1a 100644 --- a/bgpd/bgp_mac.h +++ b/bgpd/bgp_mac.h @@ -36,7 +36,7 @@ void bgp_mac_dump_table(struct vty *vty); /* * Function to lookup the prefix and see if we have a matching mac */ -bool bgp_mac_entry_exists(struct prefix *p); -bool bgp_mac_exist(struct ethaddr *mac); +bool bgp_mac_entry_exists(const struct prefix *p); +bool bgp_mac_exist(const struct ethaddr *mac); #endif diff --git a/bgpd/bgp_pbr.c b/bgpd/bgp_pbr.c index 172ec8b42e..fd3fad63f5 100644 --- a/bgpd/bgp_pbr.c +++ b/bgpd/bgp_pbr.c @@ -685,9 +685,9 @@ static int bgp_pbr_validate_policy_route(struct bgp_pbr_entry_main *api) } /* return -1 if build or validation failed */ -int bgp_pbr_build_and_validate_entry(struct prefix *p, - struct bgp_path_info *path, - struct bgp_pbr_entry_main *api) +int bgp_pbr_build_and_validate_entry(const struct prefix *p, + struct bgp_path_info *path, + struct bgp_pbr_entry_main *api) { int ret; int i, action_count = 0; @@ -2610,7 +2610,7 @@ static void bgp_pbr_handle_entry(struct bgp *bgp, struct bgp_path_info *path, } } -void bgp_pbr_update_entry(struct bgp *bgp, struct prefix *p, +void bgp_pbr_update_entry(struct bgp *bgp, const struct prefix *p, struct bgp_path_info *info, afi_t afi, safi_t safi, bool nlri_update) { diff --git a/bgpd/bgp_pbr.h b/bgpd/bgp_pbr.h index 393b08da48..47d5e21692 100644 --- a/bgpd/bgp_pbr.h +++ b/bgpd/bgp_pbr.h @@ -291,7 +291,7 @@ void bgp_pbr_print_policy_route(struct bgp_pbr_entry_main *api); struct bgp_node; struct bgp_path_info; -extern void bgp_pbr_update_entry(struct bgp *bgp, struct prefix *p, +extern void bgp_pbr_update_entry(struct bgp *bgp, const struct prefix *p, struct bgp_path_info *new_select, afi_t afi, safi_t safi, bool nlri_update); @@ -301,7 +301,7 @@ extern void bgp_pbr_reset(struct bgp *bgp, afi_t afi); extern struct bgp_pbr_interface *bgp_pbr_interface_lookup(const char *name, struct bgp_pbr_interface_head *head); -extern int bgp_pbr_build_and_validate_entry(struct prefix *p, +extern int bgp_pbr_build_and_validate_entry(const struct prefix *p, struct bgp_path_info *path, struct bgp_pbr_entry_main *api); #endif /* __BGP_PBR_H__ */ diff --git a/bgpd/bgp_rd.c b/bgpd/bgp_rd.c index ea97583495..5facf3269e 100644 --- a/bgpd/bgp_rd.c +++ b/bgpd/bgp_rd.c @@ -76,7 +76,7 @@ void decode_rd_as4(const uint8_t *pnt, struct rd_as *rd_as) } /* type == RD_TYPE_IP */ -void decode_rd_ip(uint8_t *pnt, struct rd_ip *rd_ip) +void decode_rd_ip(const uint8_t *pnt, struct rd_ip *rd_ip) { memcpy(&rd_ip->ip, pnt, 4); pnt += 4; diff --git a/bgpd/bgp_rd.h b/bgpd/bgp_rd.h index da8c553b4b..439dfd4a31 100644 --- a/bgpd/bgp_rd.h +++ b/bgpd/bgp_rd.h @@ -59,7 +59,7 @@ extern void encode_rd_type(uint16_t, uint8_t *); extern void decode_rd_as(const uint8_t *pnt, struct rd_as *rd_as); extern void decode_rd_as4(const uint8_t *pnt, struct rd_as *rd_as); -extern void decode_rd_ip(uint8_t *pnt, struct rd_ip *rd_ip); +extern void decode_rd_ip(const uint8_t *pnt, struct rd_ip *rd_ip); #if ENABLE_BGP_VNC extern void decode_rd_vnc_eth(uint8_t *pnt, struct rd_vnc_eth *rd_vnc_eth); #endif diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 442a5051fe..e1c72d8bbd 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -116,7 +116,7 @@ DEFINE_HOOK(bgp_process, struct bgp_node *bgp_afi_node_get(struct bgp_table *table, afi_t afi, - safi_t safi, struct prefix *p, + safi_t safi, const struct prefix *p, struct prefix_rd *prd) { struct bgp_node *rn; @@ -1202,7 +1202,8 @@ int bgp_path_info_cmp_compatible(struct bgp *bgp, struct bgp_path_info *new, return ret; } -static enum filter_type bgp_input_filter(struct peer *peer, struct prefix *p, +static enum filter_type bgp_input_filter(struct peer *peer, + const struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) { @@ -1322,7 +1323,7 @@ static bool bgp_cluster_filter(struct peer *peer, struct attr *attr) return false; } -static int bgp_input_modifier(struct peer *peer, struct prefix *p, +static int bgp_input_modifier(struct peer *peer, const struct prefix *p, struct attr *attr, afi_t afi, safi_t safi, const char *rmap_name, mpls_label_t *label, uint32_t num_labels, struct bgp_node *rn) @@ -3258,7 +3259,7 @@ static bool bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi, return ret; } -int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id, +int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id, struct attr *attr, afi_t afi, safi_t safi, int type, int sub_type, struct prefix_rd *prd, mpls_label_t *label, uint32_t num_labels, int soft_reconfig, @@ -6614,7 +6615,7 @@ static void bgp_remove_route_from_aggregate(struct bgp *bgp, afi_t afi, lcommunity, atomic_aggregate, aggregate); } -void bgp_aggregate_increment(struct bgp *bgp, struct prefix *p, +void bgp_aggregate_increment(struct bgp *bgp, const struct prefix *p, struct bgp_path_info *pi, afi_t afi, safi_t safi) { struct bgp_node *child; @@ -6647,7 +6648,7 @@ void bgp_aggregate_increment(struct bgp *bgp, struct prefix *p, bgp_unlock_node(child); } -void bgp_aggregate_decrement(struct bgp *bgp, struct prefix *p, +void bgp_aggregate_decrement(struct bgp *bgp, const struct prefix *p, struct bgp_path_info *del, afi_t afi, safi_t safi) { struct bgp_node *child; diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h index 7115f2668e..36d15fabc7 100644 --- a/bgpd/bgp_route.h +++ b/bgpd/bgp_route.h @@ -510,7 +510,7 @@ extern bool bgp_outbound_policy_exists(struct peer *, struct bgp_filter *); extern bool bgp_inbound_policy_exists(struct peer *, struct bgp_filter *); extern struct bgp_node *bgp_afi_node_get(struct bgp_table *table, afi_t afi, - safi_t safi, struct prefix *p, + safi_t safi, const struct prefix *p, struct prefix_rd *prd); extern struct bgp_path_info *bgp_path_info_lock(struct bgp_path_info *path); extern struct bgp_path_info *bgp_path_info_unlock(struct bgp_path_info *path); @@ -558,9 +558,12 @@ extern int bgp_static_unset_safi(afi_t afi, safi_t safi, struct vty *, const char *, const char *, const char *); /* this is primarily for MPLS-VPN */ -extern int bgp_update(struct peer *, struct prefix *, uint32_t, struct attr *, - afi_t, safi_t, int, int, struct prefix_rd *, - mpls_label_t *, uint32_t, int, struct bgp_route_evpn *); +extern int bgp_update(struct peer *peer, const struct prefix *p, + uint32_t addpath_id, struct attr *attr, + afi_t afi, safi_t safi, int type, int sub_type, + struct prefix_rd *prd, mpls_label_t *label, + uint32_t num_labels, int soft_reconfig, + struct bgp_route_evpn *evpn); extern int bgp_withdraw(struct peer *, struct prefix *, uint32_t, struct attr *, afi_t, safi_t, int, int, struct prefix_rd *, mpls_label_t *, uint32_t, struct bgp_route_evpn *); @@ -583,10 +586,10 @@ extern void bgp_aggregate_delete(struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, struct bgp_aggregate *aggregate); extern void bgp_aggregate_route(struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, struct bgp_aggregate *aggregate); -extern void bgp_aggregate_increment(struct bgp *bgp, struct prefix *p, +extern void bgp_aggregate_increment(struct bgp *bgp, const struct prefix *p, struct bgp_path_info *path, afi_t afi, safi_t safi); -extern void bgp_aggregate_decrement(struct bgp *bgp, struct prefix *p, +extern void bgp_aggregate_decrement(struct bgp *bgp, const struct prefix *p, struct bgp_path_info *path, afi_t afi, safi_t safi); diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 3daef20067..95b6548c74 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -1484,7 +1484,7 @@ void bgp_zebra_announce_table(struct bgp *bgp, afi_t afi, safi_t safi) safi); } -void bgp_zebra_withdraw(struct prefix *p, struct bgp_path_info *info, +void bgp_zebra_withdraw(const struct prefix *p, struct bgp_path_info *info, struct bgp *bgp, safi_t safi) { struct zapi_route api; diff --git a/bgpd/bgp_zebra.h b/bgpd/bgp_zebra.h index b5b451092a..e546cd5da7 100644 --- a/bgpd/bgp_zebra.h +++ b/bgpd/bgp_zebra.h @@ -36,8 +36,9 @@ extern void bgp_zebra_announce(struct bgp_node *rn, const struct prefix *p, struct bgp_path_info *path, struct bgp *bgp, afi_t afi, safi_t safi); extern void bgp_zebra_announce_table(struct bgp *, afi_t, safi_t); -extern void bgp_zebra_withdraw(struct prefix *p, struct bgp_path_info *path, - struct bgp *bgp, safi_t safi); +extern void bgp_zebra_withdraw(const struct prefix *p, + struct bgp_path_info *path, struct bgp *bgp, + safi_t safi); extern void bgp_zebra_initiate_radv(struct bgp *bgp, struct peer *peer); extern void bgp_zebra_terminate_radv(struct bgp *bgp, struct peer *peer); diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c index d87292f652..435b61edf0 100644 --- a/bgpd/rfapi/rfapi.c +++ b/bgpd/rfapi/rfapi.c @@ -355,7 +355,7 @@ int rfapi_check(void *handle) void del_vnc_route(struct rfapi_descriptor *rfd, struct peer *peer, /* rfd->peer for RFP regs */ - struct bgp *bgp, safi_t safi, struct prefix *p, + struct bgp *bgp, safi_t safi, const struct prefix *p, struct prefix_rd *prd, uint8_t type, uint8_t sub_type, struct rfapi_nexthop *lnh, int kill) { @@ -557,7 +557,7 @@ void rfapi_vn_options_free(struct rfapi_vn_option *p) /* Based on bgp_redistribute_add() */ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */ - struct bgp *bgp, int safi, struct prefix *p, + struct bgp *bgp, int safi, const struct prefix *p, struct prefix_rd *prd, struct rfapi_ip_addr *nexthop, uint32_t *local_pref, uint32_t *lifetime, /* NULL => dont send lifetime */ diff --git a/bgpd/rfapi/rfapi_backend.h b/bgpd/rfapi/rfapi_backend.h index ae1f7915f5..4facc31c60 100644 --- a/bgpd/rfapi/rfapi_backend.h +++ b/bgpd/rfapi/rfapi_backend.h @@ -35,16 +35,16 @@ extern void rfapi_delete(struct bgp *); struct rfapi *bgp_rfapi_new(struct bgp *bgp); void bgp_rfapi_destroy(struct bgp *bgp, struct rfapi *h); -extern void rfapiProcessUpdate(struct peer *peer, void *rfd, struct prefix *p, - struct prefix_rd *prd, struct attr *attr, - afi_t afi, safi_t safi, uint8_t type, - uint8_t sub_type, uint32_t *label); +extern void rfapiProcessUpdate(struct peer *peer, void *rfd, + const struct prefix *p, struct prefix_rd *prd, + struct attr *attr, afi_t afi, safi_t safi, + uint8_t type, uint8_t sub_type, uint32_t *label); -extern void rfapiProcessWithdraw(struct peer *peer, void *rfd, struct prefix *p, - struct prefix_rd *prd, struct attr *attr, - afi_t afi, safi_t safi, uint8_t type, - int kill); +extern void rfapiProcessWithdraw(struct peer *peer, void *rfd, + const struct prefix *p, struct prefix_rd *prd, + struct attr *attr, afi_t afi, safi_t safi, + uint8_t type, int kill); extern void rfapiProcessPeerDown(struct peer *peer); diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index 6c50092e6a..f31ecc0175 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -2153,7 +2153,7 @@ static void rfapiItBiIndexDump(struct agg_node *rn) static struct bgp_path_info *rfapiItBiIndexSearch( struct agg_node *rn, /* Import table VPN node */ struct prefix_rd *prd, struct peer *peer, - struct prefix *aux_prefix) /* optional L3 addr for L2 ITs */ + const struct prefix *aux_prefix) /* optional L3 addr for L2 ITs */ { struct skiplist *sl; int rc; @@ -2847,11 +2847,13 @@ rfapiBiStartWithdrawTimer(struct rfapi_import_table *import_table, } -typedef void(rfapi_bi_filtered_import_f)(struct rfapi_import_table *, int, - struct peer *, void *, struct prefix *, - struct prefix *, afi_t, - struct prefix_rd *, struct attr *, - uint8_t, uint8_t, uint32_t *); +typedef void(rfapi_bi_filtered_import_f)(struct rfapi_import_table *table, + int action, struct peer *peer, + void *rfd, const struct prefix *prefix, + const struct prefix *aux_prefix, + afi_t afi, struct prefix_rd *prd, + struct attr *attr, uint8_t type, + uint8_t sub_type, uint32_t *label); static void rfapiExpireEncapNow(struct rfapi_import_table *it, @@ -2900,11 +2902,11 @@ static int rfapiGetNexthop(struct attr *attr, struct prefix *prefix) static void rfapiBgpInfoFilteredImportEncap( struct rfapi_import_table *import_table, int action, struct peer *peer, void *rfd, /* set for looped back routes */ - struct prefix *p, - struct prefix *aux_prefix, /* Unused for encap routes */ + const struct prefix *p, + const struct prefix *aux_prefix, /* Unused for encap routes */ afi_t afi, struct prefix_rd *prd, struct attr *attr, /* part of bgp_path_info */ - uint8_t type, /* part of bgp_path_info */ + uint8_t type, /* part of bgp_path_info */ uint8_t sub_type, /* part of bgp_path_info */ uint32_t *label) /* part of bgp_path_info */ { @@ -3361,11 +3363,11 @@ static void rfapiExpireVpnNow(struct rfapi_import_table *it, void rfapiBgpInfoFilteredImportVPN( struct rfapi_import_table *import_table, int action, struct peer *peer, void *rfd, /* set for looped back routes */ - struct prefix *p, - struct prefix *aux_prefix, /* AFI_L2VPN: optional IP */ + const struct prefix *p, + const struct prefix *aux_prefix, /* AFI_L2VPN: optional IP */ afi_t afi, struct prefix_rd *prd, struct attr *attr, /* part of bgp_path_info */ - uint8_t type, /* part of bgp_path_info */ + uint8_t type, /* part of bgp_path_info */ uint8_t sub_type, /* part of bgp_path_info */ uint32_t *label) /* part of bgp_path_info */ { @@ -3840,11 +3842,11 @@ void rfapiBgpInfoFilteredImportVPN( static void rfapiBgpInfoFilteredImportBadSafi( struct rfapi_import_table *import_table, int action, struct peer *peer, void *rfd, /* set for looped back routes */ - struct prefix *p, - struct prefix *aux_prefix, /* AFI_L2VPN: optional IP */ + const struct prefix *p, + const struct prefix *aux_prefix, /* AFI_L2VPN: optional IP */ afi_t afi, struct prefix_rd *prd, struct attr *attr, /* part of bgp_path_info */ - uint8_t type, /* part of bgp_path_info */ + uint8_t type, /* part of bgp_path_info */ uint8_t sub_type, /* part of bgp_path_info */ uint32_t *label) /* part of bgp_path_info */ { @@ -3870,7 +3872,7 @@ rfapiBgpInfoFilteredImportFunction(safi_t safi) void rfapiProcessUpdate(struct peer *peer, void *rfd, /* set when looped from RFP/RFAPI */ - struct prefix *p, struct prefix_rd *prd, + const struct prefix *p, struct prefix_rd *prd, struct attr *attr, afi_t afi, safi_t safi, uint8_t type, uint8_t sub_type, uint32_t *label) { @@ -3954,7 +3956,7 @@ void rfapiProcessUpdate(struct peer *peer, } -void rfapiProcessWithdraw(struct peer *peer, void *rfd, struct prefix *p, +void rfapiProcessWithdraw(struct peer *peer, void *rfd, const struct prefix *p, struct prefix_rd *prd, struct attr *attr, afi_t afi, safi_t safi, uint8_t type, int kill) { diff --git a/bgpd/rfapi/rfapi_import.h b/bgpd/rfapi/rfapi_import.h index 1ab9cc5193..50093111c2 100644 --- a/bgpd/rfapi/rfapi_import.h +++ b/bgpd/rfapi/rfapi_import.h @@ -143,11 +143,11 @@ extern void rfapiUnicastNexthop2Prefix(afi_t afi, struct attr *attr, extern void rfapiBgpInfoFilteredImportVPN( struct rfapi_import_table *import_table, int action, struct peer *peer, void *rfd, /* set for looped back routes */ - struct prefix *p, - struct prefix *aux_prefix, /* AFI_ETHER: optional IP */ + const struct prefix *p, + const struct prefix *aux_prefix, /* AFI_ETHER: optional IP */ afi_t afi, struct prefix_rd *prd, struct attr *attr, /* part of bgp_path_info */ - uint8_t type, /* part of bgp_path_info */ + uint8_t type, /* part of bgp_path_info */ uint8_t sub_type, /* part of bgp_path_info */ uint32_t *label); /* part of bgp_path_info */ diff --git a/bgpd/rfapi/rfapi_private.h b/bgpd/rfapi/rfapi_private.h index ff1cf7ef42..3baccee7cc 100644 --- a/bgpd/rfapi/rfapi_private.h +++ b/bgpd/rfapi/rfapi_private.h @@ -281,7 +281,7 @@ extern int rfapi_find_rfd(struct bgp *bgp, struct rfapi_ip_addr *vn_addr, extern void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie + UN addr for VPN */ - struct bgp *bgp, int safi, struct prefix *p, + struct bgp *bgp, int safi, const struct prefix *p, struct prefix_rd *prd, struct rfapi_ip_addr *nexthop, uint32_t *local_pref, /* host byte order */ uint32_t *lifetime, /* host byte order */ @@ -297,7 +297,7 @@ add_vnc_route(struct rfapi_descriptor *rfd, /* cookie + UN addr for VPN */ #endif extern void del_vnc_route(struct rfapi_descriptor *rfd, struct peer *peer, - struct bgp *bgp, safi_t safi, struct prefix *p, + struct bgp *bgp, safi_t safi, const struct prefix *p, struct prefix_rd *prd, uint8_t type, uint8_t sub_type, struct rfapi_nexthop *lnh, int kill); diff --git a/bgpd/rfapi/vnc_export_bgp.c b/bgpd/rfapi/vnc_export_bgp.c index 3d34d696b5..3fe0fdaedb 100644 --- a/bgpd/rfapi/vnc_export_bgp.c +++ b/bgpd/rfapi/vnc_export_bgp.c @@ -1633,7 +1633,7 @@ void vnc_direct_bgp_vpn_disable(struct bgp *bgp, afi_t afi) * caller do it? */ void vnc_direct_bgp_rh_add_route(struct bgp *bgp, afi_t afi, - struct prefix *prefix, struct peer *peer, + const struct prefix *prefix, struct peer *peer, struct attr *attr) { struct vnc_export_info *eti; @@ -1757,7 +1757,7 @@ static int vncExportWithdrawTimer(struct thread *t) * caller do it? */ void vnc_direct_bgp_rh_del_route(struct bgp *bgp, afi_t afi, - struct prefix *prefix, struct peer *peer) + const struct prefix *prefix, struct peer *peer) { struct vnc_export_info *eti; diff --git a/bgpd/rfapi/vnc_export_bgp_p.h b/bgpd/rfapi/vnc_export_bgp_p.h index a1cb972740..bf292abb0a 100644 --- a/bgpd/rfapi/vnc_export_bgp_p.h +++ b/bgpd/rfapi/vnc_export_bgp_p.h @@ -61,12 +61,12 @@ extern void vnc_direct_bgp_reexport_group_afi(struct bgp *bgp, extern void vnc_direct_bgp_rh_add_route(struct bgp *bgp, afi_t afi, - struct prefix *prefix, + const struct prefix *prefix, struct peer *peer, struct attr *attr); extern void vnc_direct_bgp_rh_del_route(struct bgp *bgp, afi_t afi, - struct prefix *prefix, + const struct prefix *prefix, struct peer *peer); extern void vnc_direct_bgp_reexport(struct bgp *bgp, afi_t afi); diff --git a/bgpd/rfapi/vnc_export_table.c b/bgpd/rfapi/vnc_export_table.c index 5e00a1017b..8bf1479a25 100644 --- a/bgpd/rfapi/vnc_export_table.c +++ b/bgpd/rfapi/vnc_export_table.c @@ -34,7 +34,7 @@ #include "bgpd/rfapi/vnc_debug.h" struct agg_node *vnc_etn_get(struct bgp *bgp, vnc_export_type_t type, - struct prefix *p) + const struct prefix *p) { struct agg_table *t = NULL; struct agg_node *rn = NULL; @@ -66,7 +66,7 @@ struct agg_node *vnc_etn_get(struct bgp *bgp, vnc_export_type_t type, } struct agg_node *vnc_etn_lookup(struct bgp *bgp, vnc_export_type_t type, - struct prefix *p) + const struct prefix *p) { struct agg_table *t = NULL; struct agg_node *rn = NULL; @@ -98,7 +98,7 @@ struct agg_node *vnc_etn_lookup(struct bgp *bgp, vnc_export_type_t type, } struct vnc_export_info *vnc_eti_get(struct bgp *bgp, vnc_export_type_t etype, - struct prefix *p, struct peer *peer, + const struct prefix *p, struct peer *peer, uint8_t type, uint8_t subtype) { struct agg_node *etn; diff --git a/bgpd/rfapi/vnc_export_table.h b/bgpd/rfapi/vnc_export_table.h index fdb35e81e1..5dcf4e6c1d 100644 --- a/bgpd/rfapi/vnc_export_table.h +++ b/bgpd/rfapi/vnc_export_table.h @@ -46,15 +46,14 @@ struct vnc_export_info { }; extern struct agg_node *vnc_etn_get(struct bgp *bgp, vnc_export_type_t type, - struct prefix *p); + const struct prefix *p); extern struct agg_node *vnc_etn_lookup(struct bgp *bgp, vnc_export_type_t type, - struct prefix *p); + const struct prefix *p); -extern struct vnc_export_info *vnc_eti_get(struct bgp *bgp, - vnc_export_type_t etype, - struct prefix *p, struct peer *peer, - uint8_t type, uint8_t subtype); +extern struct vnc_export_info * +vnc_eti_get(struct bgp *bgp, vnc_export_type_t etype, const struct prefix *p, + struct peer *peer, uint8_t type, uint8_t subtype); extern void vnc_eti_delete(struct vnc_export_info *goner); diff --git a/bgpd/rfapi/vnc_import_bgp.c b/bgpd/rfapi/vnc_import_bgp.c index d5e509d30d..1ce5d370b0 100644 --- a/bgpd/rfapi/vnc_import_bgp.c +++ b/bgpd/rfapi/vnc_import_bgp.c @@ -104,7 +104,7 @@ uint32_t calc_local_pref(struct attr *attr, struct peer *peer) return local_pref; } -static int is_host_prefix(struct prefix *p) +static int is_host_prefix(const struct prefix *p) { switch (p->family) { case AF_INET: @@ -299,9 +299,9 @@ static void vnc_rhnck(char *tag) */ static int process_unicast_route(struct bgp *bgp, /* in */ afi_t afi, /* in */ - struct prefix *prefix, /* in */ - struct bgp_path_info *info, /* in */ - struct ecommunity **ecom, /* OUT */ + const struct prefix *prefix, /* in */ + struct bgp_path_info *info, /* in */ + struct ecommunity **ecom, /* OUT */ struct prefix *unicast_nexthop) /* OUT */ { struct rfapi_cfg *hc = bgp->rfapi_cfg; @@ -425,10 +425,10 @@ static int process_unicast_route(struct bgp *bgp, /* in */ static void vnc_import_bgp_add_route_mode_resolve_nve_one_bi( struct bgp *bgp, afi_t afi, struct bgp_path_info *bpi, /* VPN bpi */ struct prefix_rd *prd, /* RD */ - struct prefix *prefix, /* unicast route prefix */ - uint32_t *local_pref, /* NULL = no local_pref */ - uint32_t *med, /* NULL = no med */ - struct ecommunity *ecom) /* generated ecoms */ + const struct prefix *prefix, /* unicast route prefix */ + uint32_t *local_pref, /* NULL = no local_pref */ + uint32_t *med, /* NULL = no med */ + struct ecommunity *ecom) /* generated ecoms */ { struct prefix un; struct prefix nexthop; @@ -509,11 +509,12 @@ static void vnc_import_bgp_add_route_mode_resolve_nve_one_bi( } static void vnc_import_bgp_add_route_mode_resolve_nve_one_rd( - struct prefix_rd *prd, /* RD */ + struct prefix_rd *prd, /* RD */ struct bgp_table *table_rd, /* per-rd VPN route table */ - afi_t afi, struct bgp *bgp, struct prefix *prefix, /* unicast prefix */ - struct ecommunity *ecom, /* generated ecoms */ - uint32_t *local_pref, /* NULL = no local_pref */ + afi_t afi, struct bgp *bgp, + const struct prefix *prefix, /* unicast prefix */ + struct ecommunity *ecom, /* generated ecoms */ + uint32_t *local_pref, /* NULL = no local_pref */ uint32_t *med, /* NULL = no med */ struct prefix *ubpi_nexthop) /* unicast nexthop */ { @@ -552,8 +553,8 @@ static void vnc_import_bgp_add_route_mode_resolve_nve_one_rd( } static void vnc_import_bgp_add_route_mode_resolve_nve( - struct bgp *bgp, struct prefix *prefix, /* unicast prefix */ - struct bgp_path_info *info) /* unicast info */ + struct bgp *bgp, const struct prefix *prefix, /* unicast prefix */ + struct bgp_path_info *info) /* unicast info */ { afi_t afi = family2afi(prefix->family); @@ -686,7 +687,7 @@ static void vnc_import_bgp_add_route_mode_resolve_nve( static void vnc_import_bgp_add_route_mode_plain(struct bgp *bgp, - struct prefix *prefix, + const struct prefix *prefix, struct bgp_path_info *info) { afi_t afi = family2afi(prefix->family); @@ -874,10 +875,9 @@ static void vnc_import_bgp_add_route_mode_plain(struct bgp *bgp, ecommunity_free(&ecom); } -static void -vnc_import_bgp_add_route_mode_nvegroup(struct bgp *bgp, struct prefix *prefix, - struct bgp_path_info *info, - struct rfapi_nve_group_cfg *rfg) +static void vnc_import_bgp_add_route_mode_nvegroup( + struct bgp *bgp, const struct prefix *prefix, + struct bgp_path_info *info, struct rfapi_nve_group_cfg *rfg) { afi_t afi = family2afi(prefix->family); struct peer *peer = info->peer; @@ -1080,7 +1080,7 @@ vnc_import_bgp_add_route_mode_nvegroup(struct bgp *bgp, struct prefix *prefix, } static void vnc_import_bgp_del_route_mode_plain(struct bgp *bgp, - struct prefix *prefix, + const struct prefix *prefix, struct bgp_path_info *info) { struct prefix_rd prd; @@ -1153,7 +1153,7 @@ static void vnc_import_bgp_del_route_mode_plain(struct bgp *bgp, } static void vnc_import_bgp_del_route_mode_nvegroup(struct bgp *bgp, - struct prefix *prefix, + const struct prefix *prefix, struct bgp_path_info *info) { struct prefix_rd prd; @@ -1236,7 +1236,7 @@ static void vnc_import_bgp_del_route_mode_nvegroup(struct bgp *bgp, static void vnc_import_bgp_del_route_mode_resolve_nve_one_bi( struct bgp *bgp, afi_t afi, struct bgp_path_info *bpi, /* VPN bpi */ struct prefix_rd *prd, /* RD */ - struct prefix *prefix) /* unicast route prefix */ + const struct prefix *prefix) /* unicast route prefix */ { struct prefix un; @@ -1272,8 +1272,9 @@ static void vnc_import_bgp_del_route_mode_resolve_nve_one_bi( static void vnc_import_bgp_del_route_mode_resolve_nve_one_rd( struct prefix_rd *prd, struct bgp_table *table_rd, /* per-rd VPN route table */ - afi_t afi, struct bgp *bgp, struct prefix *prefix, /* unicast prefix */ - struct prefix *ubpi_nexthop) /* unicast bpi's nexthop */ + afi_t afi, struct bgp *bgp, + const struct prefix *prefix, /* unicast prefix */ + const struct prefix *ubpi_nexthop) /* unicast bpi's nexthop */ { struct bgp_node *bn; struct bgp_path_info *bpi; @@ -1312,7 +1313,7 @@ static void vnc_import_bgp_del_route_mode_resolve_nve_one_rd( static void vnc_import_bgp_del_route_mode_resolve_nve(struct bgp *bgp, afi_t afi, - struct prefix *prefix, + const struct prefix *prefix, struct bgp_path_info *info) { struct ecommunity *ecom = NULL; @@ -1396,7 +1397,7 @@ vnc_import_bgp_del_route_mode_resolve_nve(struct bgp *bgp, afi_t afi, void vnc_import_bgp_add_vnc_host_route_mode_resolve_nve( struct bgp *bgp, struct prefix_rd *prd, /* RD */ struct bgp_table *table_rd, /* per-rd VPN route table */ - struct prefix *prefix, /* VPN prefix */ + const struct prefix *prefix, /* VPN prefix */ struct bgp_path_info *bpi) /* new VPN host route */ { afi_t afi = family2afi(prefix->family); @@ -1533,7 +1534,7 @@ void vnc_import_bgp_add_vnc_host_route_mode_resolve_nve( void vnc_import_bgp_del_vnc_host_route_mode_resolve_nve( struct bgp *bgp, struct prefix_rd *prd, /* RD */ struct bgp_table *table_rd, /* per-rd VPN route table */ - struct prefix *prefix, /* VPN prefix */ + const struct prefix *prefix, /* VPN prefix */ struct bgp_path_info *bpi) /* old VPN host route */ { afi_t afi = family2afi(prefix->family); @@ -1675,8 +1676,8 @@ static int is_usable_interior_route(struct bgp_path_info *bpi_interior) */ static void vnc_import_bgp_exterior_add_route_it( struct bgp *bgp, /* exterior instance, we hope */ - struct prefix *prefix, /* unicast prefix */ - struct bgp_path_info *info, /* unicast info */ + const struct prefix *prefix, /* unicast prefix */ + struct bgp_path_info *info, /* unicast info */ struct rfapi_import_table *it_only) /* NULL, or limit to this IT */ { struct rfapi *h; @@ -1844,9 +1845,9 @@ static void vnc_import_bgp_exterior_add_route_it( } void vnc_import_bgp_exterior_add_route( - struct bgp *bgp, /* exterior instance, we hope */ - struct prefix *prefix, /* unicast prefix */ - struct bgp_path_info *info) /* unicast info */ + struct bgp *bgp, /* exterior instance, we hope */ + const struct prefix *prefix, /* unicast prefix */ + struct bgp_path_info *info) /* unicast info */ { vnc_import_bgp_exterior_add_route_it(bgp, prefix, info, NULL); } @@ -1861,8 +1862,8 @@ void vnc_import_bgp_exterior_add_route( * right routes. */ void vnc_import_bgp_exterior_del_route( - struct bgp *bgp, struct prefix *prefix, /* unicast prefix */ - struct bgp_path_info *info) /* unicast info */ + struct bgp *bgp, const struct prefix *prefix, /* unicast prefix */ + struct bgp_path_info *info) /* unicast info */ { struct rfapi *h; struct rfapi_cfg *hc; @@ -2597,7 +2598,7 @@ void vnc_import_bgp_exterior_del_route_interior( * Generic add/delete unicast routes ***********************************************************************/ -void vnc_import_bgp_add_route(struct bgp *bgp, struct prefix *prefix, +void vnc_import_bgp_add_route(struct bgp *bgp, const struct prefix *prefix, struct bgp_path_info *info) { afi_t afi = family2afi(prefix->family); @@ -2666,7 +2667,7 @@ void vnc_import_bgp_add_route(struct bgp *bgp, struct prefix *prefix, /* * "Withdrawing a Route" import process */ -void vnc_import_bgp_del_route(struct bgp *bgp, struct prefix *prefix, +void vnc_import_bgp_del_route(struct bgp *bgp, const struct prefix *prefix, struct bgp_path_info *info) /* unicast info */ { afi_t afi = family2afi(prefix->family); diff --git a/bgpd/rfapi/vnc_import_bgp.h b/bgpd/rfapi/vnc_import_bgp.h index ca64e6eacc..ab2ec1a748 100644 --- a/bgpd/rfapi/vnc_import_bgp.h +++ b/bgpd/rfapi/vnc_import_bgp.h @@ -34,10 +34,12 @@ extern uint32_t calc_local_pref(struct attr *attr, struct peer *peer); extern int vnc_prefix_cmp(const void *pfx1, const void *pfx2); -extern void vnc_import_bgp_add_route(struct bgp *bgp, struct prefix *prefix, +extern void vnc_import_bgp_add_route(struct bgp *bgp, + const struct prefix *prefix, struct bgp_path_info *info); -extern void vnc_import_bgp_del_route(struct bgp *bgp, struct prefix *prefix, +extern void vnc_import_bgp_del_route(struct bgp *bgp, + const struct prefix *prefix, struct bgp_path_info *info); extern void vnc_import_bgp_redist_enable(struct bgp *bgp, afi_t afi); @@ -51,23 +53,23 @@ extern void vnc_import_bgp_exterior_redist_disable(struct bgp *bgp, afi_t afi); extern void vnc_import_bgp_exterior_add_route( struct bgp *bgp, /* exterior instance, we hope */ - struct prefix *prefix, /* unicast prefix */ + const struct prefix *prefix, /* unicast prefix */ struct bgp_path_info *info); /* unicast info */ extern void vnc_import_bgp_exterior_del_route( - struct bgp *bgp, struct prefix *prefix, /* unicast prefix */ - struct bgp_path_info *info); /* unicast info */ + struct bgp *bgp, const struct prefix *prefix, /* unicast prefix */ + struct bgp_path_info *info); /* unicast info */ extern void vnc_import_bgp_add_vnc_host_route_mode_resolve_nve( struct bgp *bgp, struct prefix_rd *prd, /* RD */ struct bgp_table *table_rd, /* per-rd VPN route table */ - struct prefix *prefix, /* VPN prefix */ + const struct prefix *prefix, /* VPN prefix */ struct bgp_path_info *bpi); /* new VPN host route */ extern void vnc_import_bgp_del_vnc_host_route_mode_resolve_nve( struct bgp *bgp, struct prefix_rd *prd, /* RD */ struct bgp_table *table_rd, /* per-rd VPN route table */ - struct prefix *prefix, /* VPN prefix */ + const struct prefix *prefix, /* VPN prefix */ struct bgp_path_info *bpi); /* old VPN host route */ #endif /* _QUAGGA_RFAPI_VNC_IMPORT_BGP_H_ */