diff options
author | David Ahern <dsa@cumulusnetworks.com> | 2015-08-27 16:07:01 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-08-28 13:32:36 -0700 |
commit | d39d14ffa24cca9f0e44aa4a63315f4c44c56a93 (patch) | |
tree | d19cc95a22ad69e2164b9b46609ce67c577af77f /include/net | |
parent | 3abef286cf2f138de353fb0b54453621de961043 (diff) |
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>
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/inetpeer.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h index f75b9e7036a2..9d9b3446731d 100644 --- a/include/net/inetpeer.h +++ b/include/net/inetpeer.h @@ -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); |