aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/xfrm.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/xfrm.h')
-rw-r--r--include/net/xfrm.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index b203e14d26b7..89174e29dca9 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -827,6 +827,14 @@ static inline bool addr_match(const void *token1, const void *token2,
827 return true; 827 return true;
828} 828}
829 829
830static inline bool addr4_match(__be32 a1, __be32 a2, u8 prefixlen)
831{
832 /* C99 6.5.7 (3): u32 << 32 is undefined behaviour */
833 if (prefixlen == 0)
834 return true;
835 return !((a1 ^ a2) & htonl(0xFFFFFFFFu << (32 - prefixlen)));
836}
837
830static __inline__ 838static __inline__
831__be16 xfrm_flowi_sport(const struct flowi *fl, const union flowi_uli *uli) 839__be16 xfrm_flowi_sport(const struct flowi *fl, const union flowi_uli *uli)
832{ 840{
@@ -1209,8 +1217,8 @@ void xfrm_flowi_addr_get(const struct flowi *fl,
1209 memcpy(&daddr->a4, &fl->u.ip4.daddr, sizeof(daddr->a4)); 1217 memcpy(&daddr->a4, &fl->u.ip4.daddr, sizeof(daddr->a4));
1210 break; 1218 break;
1211 case AF_INET6: 1219 case AF_INET6:
1212 ipv6_addr_copy((struct in6_addr *)&saddr->a6, &fl->u.ip6.saddr); 1220 *(struct in6_addr *)saddr->a6 = fl->u.ip6.saddr;
1213 ipv6_addr_copy((struct in6_addr *)&daddr->a6, &fl->u.ip6.daddr); 1221 *(struct in6_addr *)daddr->a6 = fl->u.ip6.daddr;
1214 break; 1222 break;
1215 } 1223 }
1216} 1224}