mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-09 03:47:47 +00:00
*: unify prefix copying
There are a few places in the code where we use PREFIX_COPY(_IPV4/IPV6) macro to copy a prefix. Let's always use prefix_copy function for this. This should fix CID 1482142 and 1504610. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
parent
176d039a27
commit
b08dcc3f3f
@ -227,12 +227,8 @@ int bgp_flowspec_ip_address(enum bgp_flowspec_util_nlri_t type,
|
|||||||
BGP_FLOWSPEC_STRING_DISPLAY_MAX);
|
BGP_FLOWSPEC_STRING_DISPLAY_MAX);
|
||||||
break;
|
break;
|
||||||
case BGP_FLOWSPEC_CONVERT_TO_NON_OPAQUE:
|
case BGP_FLOWSPEC_CONVERT_TO_NON_OPAQUE:
|
||||||
if (prefix) {
|
if (prefix)
|
||||||
if (prefix_local.family == AF_INET)
|
prefix_copy(prefix, &prefix_local);
|
||||||
PREFIX_COPY_IPV4(prefix, &prefix_local);
|
|
||||||
else
|
|
||||||
PREFIX_COPY_IPV6(prefix, &prefix_local);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case BGP_FLOWSPEC_VALIDATE_ONLY:
|
case BGP_FLOWSPEC_VALIDATE_ONLY:
|
||||||
default:
|
default:
|
||||||
|
@ -1538,7 +1538,7 @@ static int bgp_peer_conf_if_to_su_update_v4(struct peer *peer,
|
|||||||
*/
|
*/
|
||||||
for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc)) {
|
for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc)) {
|
||||||
if (ifc->address && (ifc->address->family == AF_INET)) {
|
if (ifc->address && (ifc->address->family == AF_INET)) {
|
||||||
PREFIX_COPY_IPV4(&p, CONNECTED_PREFIX(ifc));
|
prefix_copy(&p, CONNECTED_PREFIX(ifc));
|
||||||
if (p.prefixlen == 30) {
|
if (p.prefixlen == 30) {
|
||||||
peer->su.sa.sa_family = AF_INET;
|
peer->su.sa.sa_family = AF_INET;
|
||||||
addr = ntohl(p.u.prefix4.s_addr);
|
addr = ntohl(p.u.prefix4.s_addr);
|
||||||
|
@ -219,7 +219,7 @@ int eigrp_network_set(struct eigrp *eigrp, struct prefix *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct prefix *pref = prefix_new();
|
struct prefix *pref = prefix_new();
|
||||||
PREFIX_COPY_IPV4(pref, p);
|
prefix_copy(pref, p);
|
||||||
rn->info = (void *)pref;
|
rn->info = (void *)pref;
|
||||||
|
|
||||||
/* Schedule Router ID Update. */
|
/* Schedule Router ID Update. */
|
||||||
|
@ -481,11 +481,6 @@ extern void prefix_ipv4_free(struct prefix_ipv4 **p);
|
|||||||
extern int str2prefix_ipv4(const char *, struct prefix_ipv4 *);
|
extern int str2prefix_ipv4(const char *, struct prefix_ipv4 *);
|
||||||
extern void apply_mask_ipv4(struct prefix_ipv4 *);
|
extern void apply_mask_ipv4(struct prefix_ipv4 *);
|
||||||
|
|
||||||
#define PREFIX_COPY(DST, SRC) \
|
|
||||||
*((struct prefix *)(DST)) = *((const struct prefix *)(SRC))
|
|
||||||
#define PREFIX_COPY_IPV4(DST, SRC) \
|
|
||||||
*((struct prefix_ipv4 *)(DST)) = *((const struct prefix_ipv4 *)(SRC))
|
|
||||||
|
|
||||||
extern int prefix_ipv4_any(const struct prefix_ipv4 *);
|
extern int prefix_ipv4_any(const struct prefix_ipv4 *);
|
||||||
extern void apply_classful_mask_ipv4(struct prefix_ipv4 *);
|
extern void apply_classful_mask_ipv4(struct prefix_ipv4 *);
|
||||||
|
|
||||||
@ -503,9 +498,6 @@ extern void prefix_ipv6_free(struct prefix_ipv6 **p);
|
|||||||
extern int str2prefix_ipv6(const char *, struct prefix_ipv6 *);
|
extern int str2prefix_ipv6(const char *, struct prefix_ipv6 *);
|
||||||
extern void apply_mask_ipv6(struct prefix_ipv6 *);
|
extern void apply_mask_ipv6(struct prefix_ipv6 *);
|
||||||
|
|
||||||
#define PREFIX_COPY_IPV6(DST, SRC) \
|
|
||||||
*((struct prefix_ipv6 *)(DST)) = *((const struct prefix_ipv6 *)(SRC))
|
|
||||||
|
|
||||||
extern int ip6_masklen(struct in6_addr);
|
extern int ip6_masklen(struct in6_addr);
|
||||||
extern void masklen2ip6(const int, struct in6_addr *);
|
extern void masklen2ip6(const int, struct in6_addr *);
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ static void connected_update(struct interface *ifp, struct connected *ifc)
|
|||||||
void connected_up(struct interface *ifp, struct connected *ifc)
|
void connected_up(struct interface *ifp, struct connected *ifc)
|
||||||
{
|
{
|
||||||
afi_t afi;
|
afi_t afi;
|
||||||
struct prefix p = {0};
|
struct prefix p;
|
||||||
struct nexthop nh = {
|
struct nexthop nh = {
|
||||||
.type = NEXTHOP_TYPE_IFINDEX,
|
.type = NEXTHOP_TYPE_IFINDEX,
|
||||||
.ifindex = ifp->ifindex,
|
.ifindex = ifp->ifindex,
|
||||||
@ -225,7 +225,7 @@ void connected_up(struct interface *ifp, struct connected *ifc)
|
|||||||
/* Ensure 'down' flag is cleared */
|
/* Ensure 'down' flag is cleared */
|
||||||
UNSET_FLAG(ifc->conf, ZEBRA_IFC_DOWN);
|
UNSET_FLAG(ifc->conf, ZEBRA_IFC_DOWN);
|
||||||
|
|
||||||
PREFIX_COPY(&p, CONNECTED_PREFIX(ifc));
|
prefix_copy(&p, CONNECTED_PREFIX(ifc));
|
||||||
|
|
||||||
/* Apply mask to the network. */
|
/* Apply mask to the network. */
|
||||||
apply_mask(&p);
|
apply_mask(&p);
|
||||||
@ -277,9 +277,9 @@ void connected_up(struct interface *ifp, struct connected *ifc)
|
|||||||
* resolve to the same network and mask
|
* resolve to the same network and mask
|
||||||
*/
|
*/
|
||||||
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, c)) {
|
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, c)) {
|
||||||
struct prefix cp = {0};
|
struct prefix cp;
|
||||||
|
|
||||||
PREFIX_COPY(&cp, CONNECTED_PREFIX(c));
|
prefix_copy(&cp, CONNECTED_PREFIX(c));
|
||||||
apply_mask(&cp);
|
apply_mask(&cp);
|
||||||
|
|
||||||
if (prefix_same(&cp, &p) &&
|
if (prefix_same(&cp, &p) &&
|
||||||
@ -412,7 +412,7 @@ void connected_down(struct interface *ifp, struct connected *ifc)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PREFIX_COPY(&p, CONNECTED_PREFIX(ifc));
|
prefix_copy(&p, CONNECTED_PREFIX(ifc));
|
||||||
|
|
||||||
/* Apply mask to the network. */
|
/* Apply mask to the network. */
|
||||||
apply_mask(&p);
|
apply_mask(&p);
|
||||||
@ -450,7 +450,7 @@ void connected_down(struct interface *ifp, struct connected *ifc)
|
|||||||
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, c)) {
|
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, c)) {
|
||||||
struct prefix cp;
|
struct prefix cp;
|
||||||
|
|
||||||
PREFIX_COPY(&cp, CONNECTED_PREFIX(c));
|
prefix_copy(&cp, CONNECTED_PREFIX(c));
|
||||||
apply_mask(&cp);
|
apply_mask(&cp);
|
||||||
|
|
||||||
if (prefix_same(&p, &cp) &&
|
if (prefix_same(&p, &cp) &&
|
||||||
|
Loading…
Reference in New Issue
Block a user