Skip to contentSkip to conversation

ipv4: introduce address lifetime

PATCH In review Jiri Pirko 2 participants 2 messages Jan 24, 2013 – Jan 29, 2013

Subsystems (3)
lore
Share & tools
lore

Jiri Pirko

author
#0 lore raw

PATCH 1/1 ipv4: introduce address lifetime

There are some usecase when lifetime of ipv4 addresses might be helpful. For example:
1) initramfs networkmanager uses a DHCP daemon to learn network configuration parameters
2) initramfs networkmanager addresses, routes and DNS configuration
3) initramfs networkmanager is requested to stop
4) initramfs networkmanager stops all daemons including dhclient
5) there are addresses and routes configured but no daemon running. If the system doesn't start networkmanager for some reason, addresses and routes will be used forever, which violates RFC 2131.

This patch is essentially a backport of ivp6 address lifetime mechanism for ipv4 addresses.

Current "ip" tool supports this without any patch (since it does not distinguish between ipv4 and ipv6 addresses in this perspective.

Also, this should be back-compatible with all current netlink users.

---
 include/linux/inetdevice.h |   6 ++
 include/net/addrconf.h     |   4 +
 net/ipv4/devinet.c         | 215 +++++++++++++++++++++++++++++++++++++++++++--
 net/ipv6/addrconf.c        |   4 -
 4 files changed, 220 insertions(+), 9 deletions(-)
include/linux/inetdevice.h +6 -0
index a9d8289..ea1e3b8 100644
@@ -166,6 +166,12 @@ struct in_ifaddr {
 	unsigned char		ifa_flags;
 	unsigned char		ifa_prefixlen;
 	char			ifa_label[IFNAMSIZ];
+
+	/* In seconds, relative to tstamp. Expiry is at tstamp + HZ * lft. */
+	__u32			ifa_valid_lft;
+	__u32			ifa_preferred_lft;
+	unsigned long		ifa_cstamp; /* created timestamp */
+	unsigned long		ifa_tstamp; /* updated timestamp */
 };
 
 extern int register_inetaddr_notifier(struct notifier_block *nb);
include/net/addrconf.h +4 -0
index 6c58d50..40be2a0 100644
@@ -15,6 +15,10 @@
 
 #define IPV6_MAX_ADDRESSES		16
 
+#define ADDRCONF_TIMER_FUZZ_MINUS	(HZ > 50 ? HZ / 50 : 1)
+#define ADDRCONF_TIMER_FUZZ		(HZ / 4)
+#define ADDRCONF_TIMER_FUZZ_MAX		(HZ)
+
 #include <linux/in.h>
 #include <linux/in6.h>
 
net/ipv4/devinet.c +210 -5

311 lines not on this page · raw message

net/ipv6/addrconf.c +0 -4
index 80d5980..7f7332b 100644
@@ -110,10 +110,6 @@ static inline u32 cstamp_delta(unsigned long cstamp)
 	return (cstamp - INITIAL_JIFFIES) * 100UL / HZ;
 }
 
-#define ADDRCONF_TIMER_FUZZ_MINUS	(HZ > 50 ? HZ/50 : 1)
-#define ADDRCONF_TIMER_FUZZ		(HZ / 4)
-#define ADDRCONF_TIMER_FUZZ_MAX		(HZ)
-
 #ifdef CONFIG_SYSCTL
 static void addrconf_sysctl_register(struct inet6_dev *idev);
 static void addrconf_sysctl_unregister(struct inet6_dev *idev);
Signature · 1 line
1.8.1
maintainer
#1 lore raw

From: Jiri Pirko <[email protected]>
Date: Thu, 24 Jan 2013 20:41:41 +0100

Quoted 14 lines

There are some usecase when lifetime of ipv4 addresses might be helpful. For example:
1) initramfs networkmanager uses a DHCP daemon to learn network configuration parameters
2) initramfs networkmanager addresses, routes and DNS configuration
3) initramfs networkmanager is requested to stop
4) initramfs networkmanager stops all daemons including dhclient
5) there are addresses and routes configured but no daemon running. If the system doesn't start networkmanager for some reason, addresses and routes will be used forever, which violates RFC 2131.

This patch is essentially a backport of ivp6 address lifetime mechanism for ipv4 addresses.

Quoted 7 lines

Current "ip" tool supports this without any patch (since it does not distinguish between ipv4 and ipv6 addresses in this perspective.

Also, this should be back-compatible with all current netlink users.

Seems reasonable, applied, thanks.