diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/inetdevice.h | 20 | ||||
| -rw-r--r-- | include/linux/rtnetlink.h | 13 |
2 files changed, 33 insertions, 0 deletions
diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h index 6fafb27877a7..e04b71cd9e73 100644 --- a/include/linux/inetdevice.h +++ b/include/linux/inetdevice.h @@ -7,6 +7,7 @@ #include <linux/netdevice.h> #include <linux/rcupdate.h> #include <linux/timer.h> +#include <linux/rtnetlink.h> struct ipv4_devconf { @@ -131,6 +132,25 @@ static __inline__ int bad_mask(u32 mask, u32 addr) return 0; } +static inline int inet_ifa_match_local_prefixlen(struct ifaddrmsg *ifm, + struct in_ifaddr *ifa) +{ + int real_prefixlen = IFA_REAL_DEL_PREFIX(ifm->ifa_prefixlen); + + /* + * Since the prefix length hasn't been taken into account in + * previous kernel versions, parts of the userspace rely on the fact + * that the deletion of an address without specifying a prefix works. + * We cannot break this and thus a prefix length of 32 still represents + * a wildcard if no exact match is requested. + */ + if (real_prefixlen != 32 || ifm->ifa_prefixlen & IFA_PREFIX_EXACT_DEL) + if (real_prefixlen != ifa->ifa_prefixlen) + return 0; + + return 1; +} + #define for_primary_ifa(in_dev) { struct in_ifaddr *ifa; \ for (ifa = (in_dev)->ifa_list; ifa && !(ifa->ifa_flags&IFA_F_SECONDARY); ifa = ifa->ifa_next) diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h index dbfe0df7795f..b3fec31e7e6f 100644 --- a/include/linux/rtnetlink.h +++ b/include/linux/rtnetlink.h @@ -397,6 +397,19 @@ enum #define IFA_MAX (__IFA_MAX - 1) +/* + * Quirk for IPv4 address deletion to allow exact deletion of equal + * addresses varying only in prefix length. A explicit exact comparison + * of the prefix length will only be done if IFA_PREFIX_EXACT_DEL is + * ORed to ifa_prefixlen. + * + * Note: This special treatment is only understood while deleting + * addresses and will lead to unexpected behaviour if used + * otherwise. + */ +#define IFA_PREFIX_EXACT_DEL 0x40 +#define IFA_REAL_DEL_PREFIX(l) ((l) & 0x3f) + /* ifa_flags */ #define IFA_F_SECONDARY 0x01 |
