Getting creation and modification time of an IPv6 interface address

Hartmut.Brandt at dlr.de Hartmut.Brandt at dlr.de
Wed Nov 25 18:22:12 UTC 2009


Hi,

I'm working on the IpAddressTable for bsnmpd. This table has two rows ipAddressCreated and ipAddressLastUpdated which seem to
correspond to the created and changed fields of the struct in6_ifaddr. Because there seems no way (except for poking in the
kernel memory) to get at these values I have added an ioctl to get them much in the spirit of the other ioctls for IPv6 addresses.

I'm not sure how the ioctl codes are allocated so I just took the next available one. If this looks ok and there are no principal problems,
I would like to commit that.

harti

Index: in6.c
===================================================================
RCS file: /usr/cvsup/src/sys/netinet6/in6.c,v
retrieving revision 1.121.2.8
diff -u -r1.121.2.8 in6.c
--- in6.c	28 Oct 2009 21:45:25 -0000	1.121.2.8
+++ in6.c	25 Nov 2009 17:41:40 -0000
@@ -312,6 +312,7 @@
 	case SIOCSIFALIFETIME_IN6:
 	case SIOCGIFSTAT_IN6:
 	case SIOCGIFSTAT_ICMP6:
+	case SIOCGIFATIMES_IN6:
 		sa6 = &ifr->ifr_addr;
 		break;
 	default:
@@ -383,6 +384,7 @@
 	case SIOCGIFNETMASK_IN6:
 	case SIOCGIFDSTADDR_IN6:
 	case SIOCGIFALIFETIME_IN6:
+	case SIOCGIFATIMES_IN6:
 		/* must think again about its semantics */
 		if (ia == NULL) {
 			error = EADDRNOTAVAIL;
@@ -652,6 +654,11 @@
 			prelist_remove(pr);
 		EVENTHANDLER_INVOKE(ifaddr_event, ifp);
 		break;
+
+	case SIOCGIFATIMES_IN6:
+		ifr->ifr_ifru.ifru_times[0] = ia->ia6_createtime;
+		ifr->ifr_ifru.ifru_times[1] = ia->ia6_updatetime;
+		break;
 	}
 
 	default:
Index: in6_var.h
===================================================================
RCS file: /usr/cvsup/src/sys/netinet6/in6_var.h,v
retrieving revision 1.45.2.1
diff -u -r1.45.2.1 in6_var.h
--- in6_var.h	3 Aug 2009 08:13:06 -0000	1.45.2.1
+++ in6_var.h	25 Nov 2009 17:07:34 -0000
@@ -277,6 +277,7 @@
 		struct in6_ifstat ifru_stat;
 		struct icmp6_ifstat ifru_icmp6stat;
 		u_int32_t ifru_scope_id[16];
+		time_t	ifru_times[2];
 	} ifr_ifru;
 };
 
@@ -463,6 +464,8 @@
 #define SIOCAADDRCTL_POLICY	_IOW('u', 108, struct in6_addrpolicy)
 #define SIOCDADDRCTL_POLICY	_IOW('u', 109, struct in6_addrpolicy)
 
+#define	SIOCGIFATIMES_IN6	_IOWR('i', 110, struct in6_ifreq)
+
 #define IN6_IFF_ANYCAST		0x01	/* anycast address */
 #define IN6_IFF_TENTATIVE	0x02	/* tentative address */
 #define IN6_IFF_DUPLICATED	0x04	/* DAD detected duplicate */


More information about the freebsd-net mailing list