summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2005-03-15 22:14:21 -0800
committerDavid S. Miller <davem@sunset.davemloft.net>2005-03-15 22:14:21 -0800
commit8fd0dfb3a9bba91f9a3d4d08e7d00ac47a68f3e9 (patch)
tree978106da4a8a372d531d260b9581eacac7d6efdd /include/linux
parentc149bdada85031ffa345fc1a65ad7bf622786133 (diff)
[IPV4]: All deletion of equal addresses only differing by prefix length.
Signed-off-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/inetdevice.h20
-rw-r--r--include/linux/rtnetlink.h13
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