mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
net: Add helper function to compare inetpeer addresses
tcp_metrics and inetpeer both have functions to compare inetpeer addresses. Consolidate into 1 version. Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
3abef286cf
commit
d39d14ffa2
3 changed files with 19 additions and 23 deletions
|
@ -121,6 +121,22 @@ static inline struct inet_peer *inet_getpeer_v6(struct inet_peer_base *base,
|
|||
return inet_getpeer(base, &daddr, create);
|
||||
}
|
||||
|
||||
static inline int inetpeer_addr_cmp(const struct inetpeer_addr *a,
|
||||
const struct inetpeer_addr *b)
|
||||
{
|
||||
int i, n = (a->family == AF_INET ? 1 : 4);
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if (a->addr.a6[i] == b->addr.a6[i])
|
||||
continue;
|
||||
if ((__force u32)a->addr.a6[i] < (__force u32)b->addr.a6[i])
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* can be called from BH context or outside */
|
||||
void inet_putpeer(struct inet_peer *p);
|
||||
bool inet_peer_xrlim_allow(struct inet_peer *peer, int timeout);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue