All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] Prefix List against 2.5.73
@ 2003-07-14 22:35 Krishna Kumar
  2003-07-15  1:17 ` kuznet
  0 siblings, 1 reply; 52+ messages in thread
From: Krishna Kumar @ 2003-07-14 22:35 UTC (permalink / raw)
  To: yoshfuji; +Cc: davem, netdev, linux-net, kuznet, krkumar


I am sending the latest patches against 2.5.73 and 2.4.21 with the changes
mentioned in my previous mail. I have also split the patch based on the
functionalities - prefix list and O/M flags of an RA.

At the bottom of this mail contains the patch for setting/getting O/M
flags against 2.5.73. The next three mails contain patches for prefix list
against 2.5.73, and both of these patches against 2.4.21. Please apply the
O/M flags patch before the prefix list patch.

Thanks,

- KK

---------------------------------------------------------------------------

> You do not explain why we (or kernel) NEED(s) this.
> It is not so important how SMALL it is
> though it may cause problems how LARGE it is.

I had explained the reasons for having prefix list i/f in my previous
mail. To recap :
-  User don't need to know what the definition of a prefix is, all he has
   to do is ask the kernel and get the list. Otherwise different user apps
   will have to know the definition of a prefix and parse the entry themselves.
   The parsing is non-trivial (eg the address should not LL or MC, there should
   be no nexthop and it should be added via an RA, etc).
-  The kernel code to get the prefix list is small, the top level
   inet6_dump_fib uses  either the dump_node or the dump_prefix, the
   latter being the new user interface. Having a user interface makes it easier
   to get the prefix list without significant bloat to the kernel.

> This is design issue; how we should provide L3 per-interface
> information to userspace; eg. in_device and/or inet6_dev things
> including per-interface statistics.
>
> Since I think it is not appropriate to provide per-interface
> statistics via RTM_xxxROUTE, so I don't agree to provide
> the RA infomation (i.e. Manage/Otherconf Flags) via
> RTM_xxxROUTE.
>
> Options:
>  - use RTM_xxxLINK for L3 operation
>  - introduce RTM_xxxIFACE for L3 per-interface operations

Yes, there are a couple of different ways to do this. One is as you have
suggested, but there is a problem with it. The existing RTM_GETLINK
interface returns very generic elements of the dev (mtu, hardware address,
dev statistics), while the change you suggested is specific to ipv6. I am
not sure if this is a good design to implement. Either we could use the
current (submitted) way or use a different RTM_GETADDR interface in
inet6_fill_ifaddr (and introduce RTM_IFACEFLAGS). This will be specific to
IPv6. Are you agreeable to this ?

> Well, on moving forward; you can split your patch up to 3 things:
>   1. fix routing flags
>   2. provide Managed/Otherconf flags API
>  (3. provide the prefix list API (if it IS required))
>
> I'm not against the first item.
> We need to discuss on the design related to the 2nd item.
> I don't think that we really need 3rd item.

- I am ok with 1 :-)
- I have suggested changes for 2, please let me know what you think, whether
  we can go with the old way or make the change suggested above.
- I believe we need #3 for the reasons given above.

Thanks,

- KK

----------------------- PATCH for O/M against 2.5.73 --------------------
diff -ruN linux-2.5.73.org/include/linux/rtnetlink.h PATCHES/linux-2.5.73/include/linux/rtnetlink.h
--- linux-2.5.73.org/include/linux/rtnetlink.h	2003-06-22 11:33:07.000000000 -0700
+++ PATCHES/linux-2.5.73/include/linux/rtnetlink.h	2003-07-14 12:11:51.000000000 -0700
@@ -330,6 +330,7 @@
 	IFA_LABEL,
 	IFA_BROADCAST,
 	IFA_ANYCAST,
+	IFA_IFFLAGS,
 	IFA_CACHEINFO
 };

diff -ruN linux-2.5.73.org/include/net/if_inet6.h PATCHES/linux-2.5.73/include/net/if_inet6.h
--- linux-2.5.73.org/include/net/if_inet6.h	2003-06-22 11:33:32.000000000 -0700
+++ PATCHES/linux-2.5.73/include/net/if_inet6.h	2003-07-14 10:30:59.000000000 -0700
@@ -17,6 +17,8 @@

 #include <net/snmp.h>

+#define IF_RA_OTHERCONF	0x80
+#define IF_RA_MANAGED	0x40
 #define IF_RA_RCVD	0x20
 #define IF_RS_SENT	0x10

diff -ruN linux-2.5.73.org/net/ipv6/addrconf.c PATCHES/linux-2.5.73/net/ipv6/addrconf.c
--- linux-2.5.73.org/net/ipv6/addrconf.c	2003-06-22 11:33:17.000000000 -0700
+++ PATCHES/linux-2.5.73/net/ipv6/addrconf.c	2003-07-14 12:22:07.000000000 -0700
@@ -2359,6 +2359,7 @@
 static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa,
 			     u32 pid, u32 seq, int event)
 {
+	int flags;
 	struct ifaddrmsg *ifm;
 	struct nlmsghdr  *nlh;
 	struct ifa_cacheinfo ci;
@@ -2389,6 +2390,8 @@
 		}
 		RTA_PUT(skb, IFA_CACHEINFO, sizeof(ci), &ci);
 	}
+	flags = ifa->idev->if_flags;
+	RTA_PUT(skb, IFA_IFFLAGS, sizeof(flags), &flags);
 	nlh->nlmsg_len = skb->tail - b;
 	return skb->len;

diff -ruN linux-2.5.73.org/net/ipv6/ndisc.c PATCHES/linux-2.5.73/net/ipv6/ndisc.c
--- linux-2.5.73.org/net/ipv6/ndisc.c	2003-06-22 11:32:56.000000000 -0700
+++ PATCHES/linux-2.5.73/net/ipv6/ndisc.c	2003-07-14 10:30:59.000000000 -0700
@@ -1036,6 +1036,16 @@
 		 */
 		in6_dev->if_flags |= IF_RA_RCVD;
 	}
+	/*
+	 * Remember the managed/otherconf flags from most recently
+	 * receieved RA message (RFC 2462) -- yoshfuji
+	 */
+	in6_dev->if_flags = (in6_dev->if_flags & ~(IF_RA_MANAGED|
+				IF_RA_OTHERCONF)) |
+				(ra_msg->icmph.icmp6_addrconf_managed ?
+					IF_RA_MANAGED : 0) |
+				(ra_msg->icmph.icmp6_addrconf_other ?
+					IF_RA_OTHERCONF : 0);

 	lifetime = ntohs(ra_msg->icmph.icmp6_rt_lifetime);

------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 1/4] Prefix List against 2.5.73
  2003-07-14 22:35 [PATCH 1/4] Prefix List against 2.5.73 Krishna Kumar
@ 2003-07-15  1:17 ` kuznet
  2003-07-15  6:59   ` YOSHIFUJI Hideaki / 吉藤英明
  2003-07-15 18:34   ` Krishna Kumar
  0 siblings, 2 replies; 52+ messages in thread
From: kuznet @ 2003-07-15  1:17 UTC (permalink / raw)
  To: Krishna Kumar; +Cc: yoshfuji, davem, netdev, linux-net, kuznet, krkumar

Hello!

> inet6_fill_ifaddr (and introduce RTM_IFACEFLAGS). This will be specific to
> IPv6. Are you agreeable to this ?
...
> +	IFA_IFFLAGS,

What's about ifa_flags? There is some space there, and the things
kept there now: TENTATIVE/DEPRECATED et al. are close relatives
of O/M.


> - I believe we need #3 for the reasons given above.

This does not pass through Occam's razor. Why not to give a filter to plain
RTM_GETROUTE? We did not implement filtering not because we do not want,
but because we (me, is more appropriate) are lazy.


Also, I am not sure that the interface should include things sort of

+	if ((addr_type & (IPV6_ADDR_LINKLOCAL | IPV6_ADDR_LOOPBACK |
+			IPV6_ADDR_MULTICAST)) != 0 ||
+			addr_type == IPV6_ADDR_ANY)

For kernel all they are direct routes, if the application wants to apply
some policy not formulated in terms of filters for RTM_GETROUTE, let it
to filter itself. Moreover, I used to emphasize that user of rtnetlink
should not believe to reliability of kernel filtering. It is just necessary
measure to guarantee that a new application, which is aware of a new
attribute, will behave correctly with older kernels, which are not aware
of this attribute. Not a requirement, of course.

Anyway, if you want to apply such specific policy, you can add a flag
to rtm_flags, which would say: RTM_F_OFFICIALLY_PREFIX and base filtering
on this flag, when it is given.

Alexey

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 1/4] Prefix List against 2.5.73
  2003-07-15  1:17 ` kuznet
@ 2003-07-15  6:59   ` YOSHIFUJI Hideaki / 吉藤英明
  2003-07-15 13:20     ` kuznet
  2003-07-15 18:34   ` Krishna Kumar
  1 sibling, 1 reply; 52+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2003-07-15  6:59 UTC (permalink / raw)
  To: kuznet; +Cc: krkumar, davem, netdev, linux-net, yoshfuji

In article <200307150117.FAA06705@dub.inr.ac.ru> (at Tue, 15 Jul 2003 05:17:53 +0400 (MSD)), kuznet@ms2.inr.ac.ru says:

> Hello!
> 
> > inet6_fill_ifaddr (and introduce RTM_IFACEFLAGS). This will be specific to
> > IPv6. Are you agreeable to this ?
> ...
> > +	IFA_IFFLAGS,
> 
> What's about ifa_flags? There is some space there, and the things
> kept there now: TENTATIVE/DEPRECATED et al. are close relatives
> of O/M.

Alexey, O/M are not flags for addresses, but for interfaces.
I believe we should not mix them up.

-- 
Hideaki YOSHIFUJI @ USAGI Project <yoshfuji@linux-ipv6.org>
GPG FP: 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 1/4] Prefix List against 2.5.73
  2003-07-15  6:59   ` YOSHIFUJI Hideaki / 吉藤英明
@ 2003-07-15 13:20     ` kuznet
  0 siblings, 0 replies; 52+ messages in thread
From: kuznet @ 2003-07-15 13:20 UTC (permalink / raw)
  To: YOSHIFUJIHideaki/吉藤英明
  Cc: krkumar, davem, netdev, linux-net, yoshfuji

Hello!

> > > +	IFA_IFFLAGS,
> > 
> > What's about ifa_flags? There is some space there, and the things
> > kept there now: TENTATIVE/DEPRECATED et al. are close relatives
> > of O/M.
> 
> Alexey, O/M are not flags for addresses, but for interfaces.
> I believe we should not mix them up.

OK.

But tell me, please, what is the difference between new _address_
attribute IFA_IFFLAGS and already existing address attrbute ifa_flags?
If you are going to enclose these per-interface flags to address information,
they can be enclosed within existing attrubute.

Alexey

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 1/4] Prefix List against 2.5.73
  2003-07-15  1:17 ` kuznet
  2003-07-15  6:59   ` YOSHIFUJI Hideaki / 吉藤英明
@ 2003-07-15 18:34   ` Krishna Kumar
  2003-07-16  0:11     ` Krishna Kumar
  2003-07-16  0:21     ` kuznet
  1 sibling, 2 replies; 52+ messages in thread
From: Krishna Kumar @ 2003-07-15 18:34 UTC (permalink / raw)
  To: kuznet; +Cc: yoshfuji, davem, netdev, linux-net

Hi Alexey,

>>+	IFA_IFFLAGS,
> 
> What's about ifa_flags? There is some space there, and the things
> kept there now: TENTATIVE/DEPRECATED et al. are close relatives
> of O/M.

 > > Alexey, O/M are not flags for addresses, but for interfaces.

 > > > But tell me, please, what is the difference between new _address_
 > > > attribute IFA_IFFLAGS and already existing address attrbute ifa_flags?

Conceptually these are different, one for address and one for interface. But I also
agree to your point that these can both be enclosed within one attribute to return.
If we agree to do it in this way, then we have to change the values of either of
the two sets of #defines (if_flags & ifa_flags since they intersect). I propose
changing the values of IFA_PERM/TENT/DEPRE/SECOND, etc, for no other reason other
than the MANAGED/OTHER flags has values copied off from the RA (bitwise values of
the icmpv6_nd_ra field of RA). It might make more meaning to keep 0x80 for field 'M'
which is the first bit of the field, but let me know if this is not acceptable.

> This does not pass through Occam's razor. Why not to give a filter to plain
> RTM_GETROUTE? We did not implement filtering not because we do not want,
> but because we (me, is more appropriate) are lazy.

OK, I can change that to give a filter. Is it OK to add the filter to rtm_flags ?
I was thinking of adding RTM_F_PREFIX, and rt6_dump_route() can pass this information
to rt6_fill_node() which does filtering of routes based on whether this flag is set
or not. Did I understand you correctly here ?

> Also, I am not sure that the interface should include things sort of
> 
> +	if ((addr_type & (IPV6_ADDR_LINKLOCAL | IPV6_ADDR_LOOPBACK |
> +			IPV6_ADDR_MULTICAST)) != 0 ||
> +			addr_type == IPV6_ADDR_ANY)
> 

I can remove the check completely and introduce a new flag RTF_PREFIX_RT to distinguish
between various route types.

Are these modifications OK ?

Thanks,

- KK

> For kernel all they are direct routes, if the application wants to apply
> some policy not formulated in terms of filters for RTM_GETROUTE, let it
> to filter itself. Moreover, I used to emphasize that user of rtnetlink
> should not believe to reliability of kernel filtering. It is just necessary
> measure to guarantee that a new application, which is aware of a new
> attribute, will behave correctly with older kernels, which are not aware
> of this attribute. Not a requirement, of course.
> 
> Anyway, if you want to apply such specific policy, you can add a flag
> to rtm_flags, which would say: RTM_F_OFFICIALLY_PREFIX and base filtering
> on this flag, when it is given.
> 
> Alexey
> 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 1/4] Prefix List against 2.5.73
  2003-07-15 18:34   ` Krishna Kumar
@ 2003-07-16  0:11     ` Krishna Kumar
  2003-07-16  0:21     ` kuznet
  1 sibling, 0 replies; 52+ messages in thread
From: Krishna Kumar @ 2003-07-16  0:11 UTC (permalink / raw)
  To: Krishna Kumar; +Cc: kuznet, yoshfuji, davem, netdev, linux-net

 > I proposechanging the values of IFA_PERM/TENT/DEPRE/SECOND, etc,

On the other hand, to maintain compatibility with existing apps (ip command),
I can change the new values instead. So now the same ip util program will
display the correct flag values for the address and then display the remaining
flags which are the O/M flags.

I will send patch for this tomorrow.

Thanks,

- KK

> Hi Alexey,
> 
>>> +    IFA_IFFLAGS,
>>
>>
>> What's about ifa_flags? There is some space there, and the things
>> kept there now: TENTATIVE/DEPRECATED et al. are close relatives
>> of O/M.
> 
> 
>  > > Alexey, O/M are not flags for addresses, but for interfaces.
> 
>  > > > But tell me, please, what is the difference between new _address_
>  > > > attribute IFA_IFFLAGS and already existing address attrbute 
> ifa_flags?
> 
> Conceptually these are different, one for address and one for interface. 
> But I also
> agree to your point that these can both be enclosed within one attribute 
> to return.
> If we agree to do it in this way, then we have to change the values of 
> either of
> the two sets of #defines (if_flags & ifa_flags since they intersect). I 
> propose
> changing the values of IFA_PERM/TENT/DEPRE/SECOND, etc, for no other 
> reason other
> than the MANAGED/OTHER flags has values copied off from the RA (bitwise 
> values of
> the icmpv6_nd_ra field of RA). It might make more meaning to keep 0x80 
> for field 'M'
> which is the first bit of the field, but let me know if this is not 
> acceptable.
> 
>> This does not pass through Occam's razor. Why not to give a filter to 
>> plain
>> RTM_GETROUTE? We did not implement filtering not because we do not want,
>> but because we (me, is more appropriate) are lazy.
> 
> 
> OK, I can change that to give a filter. Is it OK to add the filter to 
> rtm_flags ?
> I was thinking of adding RTM_F_PREFIX, and rt6_dump_route() can pass 
> this information
> to rt6_fill_node() which does filtering of routes based on whether this 
> flag is set
> or not. Did I understand you correctly here ?
> 
>> Also, I am not sure that the interface should include things sort of
>>
>> +    if ((addr_type & (IPV6_ADDR_LINKLOCAL | IPV6_ADDR_LOOPBACK |
>> +            IPV6_ADDR_MULTICAST)) != 0 ||
>> +            addr_type == IPV6_ADDR_ANY)
>>
> 
> I can remove the check completely and introduce a new flag RTF_PREFIX_RT 
> to distinguish
> between various route types.
> 
> Are these modifications OK ?
> 
> Thanks,
> 
> - KK
> 
>> For kernel all they are direct routes, if the application wants to apply
>> some policy not formulated in terms of filters for RTM_GETROUTE, let it
>> to filter itself. Moreover, I used to emphasize that user of rtnetlink
>> should not believe to reliability of kernel filtering. It is just 
>> necessary
>> measure to guarantee that a new application, which is aware of a new
>> attribute, will behave correctly with older kernels, which are not aware
>> of this attribute. Not a requirement, of course.
>>
>> Anyway, if you want to apply such specific policy, you can add a flag
>> to rtm_flags, which would say: RTM_F_OFFICIALLY_PREFIX and base filtering
>> on this flag, when it is given.
>>
>> Alexey
>>
> 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 1/4] Prefix List against 2.5.73
  2003-07-15 18:34   ` Krishna Kumar
  2003-07-16  0:11     ` Krishna Kumar
@ 2003-07-16  0:21     ` kuznet
  2003-07-16  8:39       ` YOSHIFUJI Hideaki / 吉藤英明
  1 sibling, 1 reply; 52+ messages in thread
From: kuznet @ 2003-07-16  0:21 UTC (permalink / raw)
  To: Krishna Kumar; +Cc: yoshfuji, davem, netdev, linux-net

Hello!

> the two sets of #defines (if_flags & ifa_flags since they intersect). I propose
> changing the values of IFA_PERM/TENT/DEPRE/SECOND,

This is almost impossible, it is an old public API.

> which is the first bit of the field, but let me know if this is not acceptable.

Select yourself: either IFA_IFFLAGS or translated flags in ifa_flags.
I prefer the second way just because it is too unpleasant to add
a new attribute for sake of two bits with no visible candidates
to use remaining ones.


> OK, I can change that to give a filter. Is it OK to add the filter to rtm_flags ?
> I was thinking of adding RTM_F_PREFIX, and rt6_dump_route() can pass this information
> to rt6_fill_node() which does filtering of routes based on whether this flag is set
> or not. Did I understand you correctly here ?

Perfectly!


> I can remove the check completely and introduce a new flag RTF_PREFIX_RT to distinguish
> between various route types.
> 
> Are these modifications OK ?

Yes, I would prefer this... Actually, it is mostly to leave possibility
to override this bit administratively. :-) If you insist this is totally
illegal and the rule must be hardwired, new flag is really redundant.

Alexey

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 1/4] Prefix List against 2.5.73
  2003-07-16  0:21     ` kuznet
@ 2003-07-16  8:39       ` YOSHIFUJI Hideaki / 吉藤英明
  2003-07-16 18:42         ` [PATCH 1/2] " Krishna Kumar
  2003-07-16 23:41         ` [PATCH 1/4] Prefix List against 2.5.73 kuznet
  0 siblings, 2 replies; 52+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2003-07-16  8:39 UTC (permalink / raw)
  To: kuznet; +Cc: krkumar, davem, netdev, yoshfuji, linux-net

Hello.

In article <200307160021.EAA10195@dub.inr.ac.ru> (at Wed, 16 Jul 2003 04:21:33 +0400 (MSD)), kuznet@ms2.inr.ac.ru says:

> Select yourself: either IFA_IFFLAGS or translated flags in ifa_flags.
> I prefer the second way just because it is too unpleasant to add
> a new attribute for sake of two bits with no visible candidates
> to use remaining ones.

Well, I dislike ifa_flags because 
 - it is conceptually wrong to combine them.
   e.g. even if all autoconf addresses expired, flags lasts and 
   we should report it to userspace.
 - ifa_flags is extremely expensive resource.
   There are only 8 bits. Use it only for addresses.

My suggestion is:
 - create L3 per-interface RTM, say, RTM_xxxIFACE.
 - provide inet_device / inet6_dev things via this RTM.
    e.g. per-interface statistics, flags etc.

-- 
Hideaki YOSHIFUJI @ USAGI Project <yoshfuji@linux-ipv6.org>
GPG FP: 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [PATCH 1/2] Prefix List against 2.5.73
  2003-07-16  8:39       ` YOSHIFUJI Hideaki / 吉藤英明
@ 2003-07-16 18:42         ` Krishna Kumar
  2003-07-16 18:49           ` Krishna Kumar
  2003-07-16 18:50           ` [PATCH 2/2] Prefix List against 2.4.21 Krishna Kumar
  2003-07-16 23:41         ` [PATCH 1/4] Prefix List against 2.5.73 kuznet
  1 sibling, 2 replies; 52+ messages in thread
From: Krishna Kumar @ 2003-07-16 18:42 UTC (permalink / raw)
  To: YOSHIFUJI Hideaki / 吉藤英明
  Cc: kuznet, davem, netdev, linux-net


Hi,

> > Select yourself: either IFA_IFFLAGS or translated flags in ifa_flags.
> > I prefer the second way just because it is too unpleasant to add
> > a new attribute for sake of two bits with no visible candidates
> > to use remaining ones.
>
> Well, I dislike ifa_flags because
>  - it is conceptually wrong to combine them.
>    e.g. even if all autoconf addresses expired, flags lasts and
>    we should report it to userspace.
>  - ifa_flags is extremely expensive resource.
>    There are only 8 bits. Use it only for addresses.

Well, I tend to agree with Alexey since we don't need a lot of extra data
support for providing 2 bits. The advantage with this approach is that the
unmodified ip util can display the flags correctly after it removes the
address specific flags. Going by the other approach, we need to support a
new type to get this information (IFA_IFFLAGS). If number of bits is
considered important, then it is possible to just return the 6 bits
(ignore the RS* bits). I feel this is less complicated of the two ways.

So at this time, I am sending the patch for 2.5.73 (is this too old ?)
using Alexey's suggestion. Patch follows for 2.4.21.

Thanks,

- KK

diff -ruN linux-2.5.73.org/include/linux/ipv6_route.h test/linux-2.5.73/include/linux/ipv6_route.h
--- linux-2.5.73.org/include/linux/ipv6_route.h	2003-06-22 11:32:36.000000000 -0700
+++ test/linux-2.5.73/include/linux/ipv6_route.h	2003-07-15 10:38:31.000000000 -0700
@@ -16,6 +16,7 @@
 #define RTF_DEFAULT	0x00010000	/* default - learned via ND	*/
 #define RTF_ALLONLINK	0x00020000	/* fallback, no routers on link	*/
 #define RTF_ADDRCONF	0x00040000	/* addrconf route - RA		*/
+#define RTF_PREFIX_RT	0x00080000	/* A prefix only route - RA	*/

 #define RTF_NONEXTHOP	0x00200000	/* route with no nexthop	*/
 #define RTF_EXPIRES	0x00400000
@@ -44,4 +45,16 @@
 #define RTMSG_NEWROUTE		0x21
 #define RTMSG_DELROUTE		0x22

+/*
+ * Return entire prefix list in array of following structures. Provides the
+ * prefix and prefix length for all devices.
+ */
+
+struct in6_prefix_msg
+{
+	int ifindex;
+	int prefix_len;
+	struct in6_addr prefix;
+};
+
 #endif
diff -ruN linux-2.5.73.org/include/linux/rtnetlink.h test/linux-2.5.73/include/linux/rtnetlink.h
--- linux-2.5.73.org/include/linux/rtnetlink.h	2003-06-22 11:33:07.000000000 -0700
+++ test/linux-2.5.73/include/linux/rtnetlink.h	2003-07-16 10:58:19.000000000 -0700
@@ -168,6 +168,7 @@
 #define RTM_F_NOTIFY		0x100	/* Notify user of route change	*/
 #define RTM_F_CLONED		0x200	/* This route is cloned		*/
 #define RTM_F_EQUALIZE		0x400	/* Multipath equalizer: NI	*/
+#define RTM_F_PREFIX		0x800	/* Prefix addresses		*/

 /* Reserved table identifiers */

diff -ruN linux-2.5.73.org/include/net/if_inet6.h test/linux-2.5.73/include/net/if_inet6.h
--- linux-2.5.73.org/include/net/if_inet6.h	2003-06-22 11:33:32.000000000 -0700
+++ test/linux-2.5.73/include/net/if_inet6.h	2003-07-16 09:55:25.000000000 -0700
@@ -17,7 +17,9 @@

 #include <net/snmp.h>

-#define IF_RA_RCVD	0x20
+#define IF_RA_OTHERCONF	0x02
+#define IF_RA_MANAGED	0x04
+#define IF_RA_RCVD	0x08
 #define IF_RS_SENT	0x10

 #ifdef __KERNEL__
diff -ruN linux-2.5.73.org/net/ipv6/addrconf.c test/linux-2.5.73/net/ipv6/addrconf.c
--- linux-2.5.73.org/net/ipv6/addrconf.c	2003-06-22 11:33:17.000000000 -0700
+++ test/linux-2.5.73/net/ipv6/addrconf.c	2003-07-16 11:01:10.000000000 -0700
@@ -129,7 +129,7 @@

 static int addrconf_ifdown(struct net_device *dev, int how);

-static void addrconf_dad_start(struct inet6_ifaddr *ifp);
+static void addrconf_dad_start(struct inet6_ifaddr *ifp, int flags);
 static void addrconf_dad_timer(unsigned long data);
 static void addrconf_dad_completed(struct inet6_ifaddr *ifp);
 static void addrconf_rs_timer(unsigned long data);
@@ -715,7 +715,7 @@
 	ift->prefered_lft = tmp_prefered_lft;
 	ift->tstamp = ifp->tstamp;
 	spin_unlock_bh(&ift->lock);
-	addrconf_dad_start(ift);
+	addrconf_dad_start(ift, 0);
 	in6_ifa_put(ift);
 	in6_dev_put(idev);
 out:
@@ -1211,7 +1211,7 @@
 	rtmsg.rtmsg_dst_len = 8;
 	rtmsg.rtmsg_metric = IP6_RT_PRIO_ADDRCONF;
 	rtmsg.rtmsg_ifindex = dev->ifindex;
-	rtmsg.rtmsg_flags = RTF_UP|RTF_ADDRCONF;
+	rtmsg.rtmsg_flags = RTF_UP;
 	rtmsg.rtmsg_type = RTMSG_NEWROUTE;
 	ip6_route_add(&rtmsg, NULL, NULL);
 }
@@ -1238,7 +1238,7 @@
 	struct in6_addr addr;

 	ipv6_addr_set(&addr,  htonl(0xFE800000), 0, 0, 0);
-	addrconf_prefix_route(&addr, 64, dev, 0, RTF_ADDRCONF);
+	addrconf_prefix_route(&addr, 64, dev, 0, 0);
 }

 static struct inet6_dev *addrconf_add_dev(struct net_device *dev)
@@ -1330,7 +1330,8 @@
 		}
 	} else if (pinfo->onlink && valid_lft) {
 		addrconf_prefix_route(&pinfo->prefix, pinfo->prefix_len,
-				      dev, rt_expires, RTF_ADDRCONF|RTF_EXPIRES);
+				      dev, rt_expires,
+				      RTF_ADDRCONF|RTF_EXPIRES|RTF_PREFIX_RT);
 	}
 	if (rt)
 		dst_release(&rt->u.dst);
@@ -1378,7 +1379,7 @@
 			}

 			create = 1;
-			addrconf_dad_start(ifp);
+			addrconf_dad_start(ifp, RTF_ADDRCONF|RTF_PREFIX_RT);
 		}

 		if (ifp && valid_lft == 0) {
@@ -1529,7 +1530,7 @@

 	ifp = ipv6_add_addr(idev, pfx, plen, scope, IFA_F_PERMANENT);
 	if (!IS_ERR(ifp)) {
-		addrconf_dad_start(ifp);
+		addrconf_dad_start(ifp, 0);
 		in6_ifa_put(ifp);
 		return 0;
 	}
@@ -1704,7 +1705,7 @@

 	ifp = ipv6_add_addr(idev, addr, 64, IFA_LINK, IFA_F_PERMANENT);
 	if (!IS_ERR(ifp)) {
-		addrconf_dad_start(ifp);
+		addrconf_dad_start(ifp, 0);
 		in6_ifa_put(ifp);
 	}
 }
@@ -1943,8 +1944,7 @@
 		memset(&rtmsg, 0, sizeof(struct in6_rtmsg));
 		rtmsg.rtmsg_type = RTMSG_NEWROUTE;
 		rtmsg.rtmsg_metric = IP6_RT_PRIO_ADDRCONF;
-		rtmsg.rtmsg_flags = (RTF_ALLONLINK | RTF_ADDRCONF |
-				     RTF_DEFAULT | RTF_UP);
+		rtmsg.rtmsg_flags = (RTF_ALLONLINK | RTF_DEFAULT | RTF_UP);

 		rtmsg.rtmsg_ifindex = ifp->idev->dev->ifindex;

@@ -1958,7 +1958,7 @@
 /*
  *	Duplicate Address Detection
  */
-static void addrconf_dad_start(struct inet6_ifaddr *ifp)
+static void addrconf_dad_start(struct inet6_ifaddr *ifp, int flags)
 {
 	struct net_device *dev;
 	unsigned long rand_num;
@@ -1968,7 +1968,7 @@
 	addrconf_join_solict(dev, &ifp->addr);

 	if (ifp->prefix_len != 128 && (ifp->flags&IFA_F_PERMANENT))
-		addrconf_prefix_route(&ifp->addr, ifp->prefix_len, dev, 0, RTF_ADDRCONF);
+		addrconf_prefix_route(&ifp->addr, ifp->prefix_len, dev, 0, flags);

 	net_srandom(ifp->addr.s6_addr32[3]);
 	rand_num = net_random() % (ifp->idev->cnf.rtr_solicit_delay ? : 1);
@@ -2368,7 +2368,7 @@
 	ifm = NLMSG_DATA(nlh);
 	ifm->ifa_family = AF_INET6;
 	ifm->ifa_prefixlen = ifa->prefix_len;
-	ifm->ifa_flags = ifa->flags;
+	ifm->ifa_flags = ifa->flags | ifa->idev->if_flags;
 	ifm->ifa_scope = RT_SCOPE_UNIVERSE;
 	if (ifa->scope&IFA_HOST)
 		ifm->ifa_scope = RT_SCOPE_HOST;
diff -ruN linux-2.5.73.org/net/ipv6/ndisc.c test/linux-2.5.73/net/ipv6/ndisc.c
--- linux-2.5.73.org/net/ipv6/ndisc.c	2003-06-22 11:32:56.000000000 -0700
+++ test/linux-2.5.73/net/ipv6/ndisc.c	2003-07-14 15:06:14.000000000 -0700
@@ -1036,6 +1036,16 @@
 		 */
 		in6_dev->if_flags |= IF_RA_RCVD;
 	}
+	/*
+	 * Remember the managed/otherconf flags from most recently
+	 * receieved RA message (RFC 2462) -- yoshfuji
+	 */
+	in6_dev->if_flags = (in6_dev->if_flags & ~(IF_RA_MANAGED|
+				IF_RA_OTHERCONF)) |
+				(ra_msg->icmph.icmp6_addrconf_managed ?
+					IF_RA_MANAGED : 0) |
+				(ra_msg->icmph.icmp6_addrconf_other ?
+					IF_RA_OTHERCONF : 0);

 	lifetime = ntohs(ra_msg->icmph.icmp6_rt_lifetime);

diff -ruN linux-2.5.73.org/net/ipv6/route.c test/linux-2.5.73/net/ipv6/route.c
--- linux-2.5.73.org/net/ipv6/route.c	2003-06-22 11:33:05.000000000 -0700
+++ test/linux-2.5.73/net/ipv6/route.c	2003-07-16 10:42:01.000000000 -0700
@@ -1400,13 +1400,20 @@
 			 struct in6_addr *src,
 			 int iif,
 			 int type, u32 pid, u32 seq,
-			 struct nlmsghdr *in_nlh)
+			 struct nlmsghdr *in_nlh, int prefix)
 {
 	struct rtmsg *rtm;
 	struct nlmsghdr  *nlh;
 	unsigned char	 *b = skb->tail;
 	struct rta_cacheinfo ci;

+	if (prefix) {	/* user wants prefix routes only */
+		if (!(rt->rt6i_flags & RTF_PREFIX_RT)) {
+			/* success since this is not a prefix route */
+			return 1;
+		}
+	}
+
 	if (!pid && in_nlh) {
 		pid = in_nlh->nlmsg_pid;
 	}
@@ -1487,10 +1494,16 @@
 static int rt6_dump_route(struct rt6_info *rt, void *p_arg)
 {
 	struct rt6_rtnl_dump_arg *arg = (struct rt6_rtnl_dump_arg *) p_arg;
+	struct rtmsg *rtm;
+	int prefix;

+	rtm = NLMSG_DATA(arg->cb->nlh);
+	if (rtm)
+		prefix = (rtm->rtm_flags & RTM_F_PREFIX) != 0;
+	else prefix = 0;
 	return rt6_fill_node(arg->skb, rt, NULL, NULL, 0, RTM_NEWROUTE,
 		     NETLINK_CB(arg->cb->skb).pid, arg->cb->nlh->nlmsg_seq,
-		     NULL);
+		     NULL, prefix);
 }

 static int fib6_dump_node(struct fib6_walker_t *w)
@@ -1638,7 +1651,7 @@
 			    &fl.fl6_dst, &fl.fl6_src,
 			    iif,
 			    RTM_NEWROUTE, NETLINK_CB(in_skb).pid,
-			    nlh->nlmsg_seq, nlh);
+			    nlh->nlmsg_seq, nlh, 0);
 	if (err < 0) {
 		err = -EMSGSIZE;
 		goto out_free;
@@ -1664,7 +1677,7 @@
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_ROUTE, ENOBUFS);
 		return;
 	}
-	if (rt6_fill_node(skb, rt, NULL, NULL, 0, event, 0, 0, nlh) < 0) {
+	if (rt6_fill_node(skb, rt, NULL, NULL, 0, event, 0, 0, nlh, 0) < 0) {
 		kfree_skb(skb);
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_ROUTE, EINVAL);
 		return;

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 1/2] Prefix List against 2.5.73
  2003-07-16 18:42         ` [PATCH 1/2] " Krishna Kumar
@ 2003-07-16 18:49           ` Krishna Kumar
  2003-07-16 18:50           ` [PATCH 2/2] Prefix List against 2.4.21 Krishna Kumar
  1 sibling, 0 replies; 52+ messages in thread
From: Krishna Kumar @ 2003-07-16 18:49 UTC (permalink / raw)
  To: YOSHIFUJI Hideaki / 吉藤英明
  Cc: kuznet, davem, netdev, linux-net


Sorry, I had an extra structure in the previous patch which is not needed
after taking alexey's changes. Now since the prefix list and the routing
table are returned *identically*, the extra structure in6_prefix_mgs is
removed. This is the correct patch for 2.5.73.

Thanks,

- KK

diff -ruN linux-2.5.73.org/include/linux/ipv6_route.h test/linux-2.5.73/include/linux/ipv6_route.h
--- linux-2.5.73.org/include/linux/ipv6_route.h	2003-06-22 11:32:36.000000000 -0700
+++ test/linux-2.5.73/include/linux/ipv6_route.h	2003-07-15 10:38:31.000000000 -0700
@@ -16,6 +16,7 @@
 #define RTF_DEFAULT	0x00010000	/* default - learned via ND	*/
 #define RTF_ALLONLINK	0x00020000	/* fallback, no routers on link	*/
 #define RTF_ADDRCONF	0x00040000	/* addrconf route - RA		*/
+#define RTF_PREFIX_RT	0x00080000	/* A prefix only route - RA	*/

 #define RTF_NONEXTHOP	0x00200000	/* route with no nexthop	*/
 #define RTF_EXPIRES	0x00400000
diff -ruN linux-2.5.73.org/include/linux/rtnetlink.h test/linux-2.5.73/include/linux/rtnetlink.h
--- linux-2.5.73.org/include/linux/rtnetlink.h	2003-06-22 11:33:07.000000000 -0700
+++ test/linux-2.5.73/include/linux/rtnetlink.h	2003-07-16 10:58:19.000000000 -0700
@@ -168,6 +168,7 @@
 #define RTM_F_NOTIFY		0x100	/* Notify user of route change	*/
 #define RTM_F_CLONED		0x200	/* This route is cloned		*/
 #define RTM_F_EQUALIZE		0x400	/* Multipath equalizer: NI	*/
+#define RTM_F_PREFIX		0x800	/* Prefix addresses		*/

 /* Reserved table identifiers */

diff -ruN linux-2.5.73.org/include/net/if_inet6.h test/linux-2.5.73/include/net/if_inet6.h
--- linux-2.5.73.org/include/net/if_inet6.h	2003-06-22 11:33:32.000000000 -0700
+++ test/linux-2.5.73/include/net/if_inet6.h	2003-07-16 09:55:25.000000000 -0700
@@ -17,7 +17,9 @@

 #include <net/snmp.h>

-#define IF_RA_RCVD	0x20
+#define IF_RA_OTHERCONF	0x02
+#define IF_RA_MANAGED	0x04
+#define IF_RA_RCVD	0x08
 #define IF_RS_SENT	0x10

 #ifdef __KERNEL__
diff -ruN linux-2.5.73.org/net/ipv6/addrconf.c test/linux-2.5.73/net/ipv6/addrconf.c
--- linux-2.5.73.org/net/ipv6/addrconf.c	2003-06-22 11:33:17.000000000 -0700
+++ test/linux-2.5.73/net/ipv6/addrconf.c	2003-07-16 11:01:10.000000000 -0700
@@ -129,7 +129,7 @@

 static int addrconf_ifdown(struct net_device *dev, int how);

-static void addrconf_dad_start(struct inet6_ifaddr *ifp);
+static void addrconf_dad_start(struct inet6_ifaddr *ifp, int flags);
 static void addrconf_dad_timer(unsigned long data);
 static void addrconf_dad_completed(struct inet6_ifaddr *ifp);
 static void addrconf_rs_timer(unsigned long data);
@@ -715,7 +715,7 @@
 	ift->prefered_lft = tmp_prefered_lft;
 	ift->tstamp = ifp->tstamp;
 	spin_unlock_bh(&ift->lock);
-	addrconf_dad_start(ift);
+	addrconf_dad_start(ift, 0);
 	in6_ifa_put(ift);
 	in6_dev_put(idev);
 out:
@@ -1211,7 +1211,7 @@
 	rtmsg.rtmsg_dst_len = 8;
 	rtmsg.rtmsg_metric = IP6_RT_PRIO_ADDRCONF;
 	rtmsg.rtmsg_ifindex = dev->ifindex;
-	rtmsg.rtmsg_flags = RTF_UP|RTF_ADDRCONF;
+	rtmsg.rtmsg_flags = RTF_UP;
 	rtmsg.rtmsg_type = RTMSG_NEWROUTE;
 	ip6_route_add(&rtmsg, NULL, NULL);
 }
@@ -1238,7 +1238,7 @@
 	struct in6_addr addr;

 	ipv6_addr_set(&addr,  htonl(0xFE800000), 0, 0, 0);
-	addrconf_prefix_route(&addr, 64, dev, 0, RTF_ADDRCONF);
+	addrconf_prefix_route(&addr, 64, dev, 0, 0);
 }

 static struct inet6_dev *addrconf_add_dev(struct net_device *dev)
@@ -1330,7 +1330,8 @@
 		}
 	} else if (pinfo->onlink && valid_lft) {
 		addrconf_prefix_route(&pinfo->prefix, pinfo->prefix_len,
-				      dev, rt_expires, RTF_ADDRCONF|RTF_EXPIRES);
+				      dev, rt_expires,
+				      RTF_ADDRCONF|RTF_EXPIRES|RTF_PREFIX_RT);
 	}
 	if (rt)
 		dst_release(&rt->u.dst);
@@ -1378,7 +1379,7 @@
 			}

 			create = 1;
-			addrconf_dad_start(ifp);
+			addrconf_dad_start(ifp, RTF_ADDRCONF|RTF_PREFIX_RT);
 		}

 		if (ifp && valid_lft == 0) {
@@ -1529,7 +1530,7 @@

 	ifp = ipv6_add_addr(idev, pfx, plen, scope, IFA_F_PERMANENT);
 	if (!IS_ERR(ifp)) {
-		addrconf_dad_start(ifp);
+		addrconf_dad_start(ifp, 0);
 		in6_ifa_put(ifp);
 		return 0;
 	}
@@ -1704,7 +1705,7 @@

 	ifp = ipv6_add_addr(idev, addr, 64, IFA_LINK, IFA_F_PERMANENT);
 	if (!IS_ERR(ifp)) {
-		addrconf_dad_start(ifp);
+		addrconf_dad_start(ifp, 0);
 		in6_ifa_put(ifp);
 	}
 }
@@ -1943,8 +1944,7 @@
 		memset(&rtmsg, 0, sizeof(struct in6_rtmsg));
 		rtmsg.rtmsg_type = RTMSG_NEWROUTE;
 		rtmsg.rtmsg_metric = IP6_RT_PRIO_ADDRCONF;
-		rtmsg.rtmsg_flags = (RTF_ALLONLINK | RTF_ADDRCONF |
-				     RTF_DEFAULT | RTF_UP);
+		rtmsg.rtmsg_flags = (RTF_ALLONLINK | RTF_DEFAULT | RTF_UP);

 		rtmsg.rtmsg_ifindex = ifp->idev->dev->ifindex;

@@ -1958,7 +1958,7 @@
 /*
  *	Duplicate Address Detection
  */
-static void addrconf_dad_start(struct inet6_ifaddr *ifp)
+static void addrconf_dad_start(struct inet6_ifaddr *ifp, int flags)
 {
 	struct net_device *dev;
 	unsigned long rand_num;
@@ -1968,7 +1968,7 @@
 	addrconf_join_solict(dev, &ifp->addr);

 	if (ifp->prefix_len != 128 && (ifp->flags&IFA_F_PERMANENT))
-		addrconf_prefix_route(&ifp->addr, ifp->prefix_len, dev, 0, RTF_ADDRCONF);
+		addrconf_prefix_route(&ifp->addr, ifp->prefix_len, dev, 0, flags);

 	net_srandom(ifp->addr.s6_addr32[3]);
 	rand_num = net_random() % (ifp->idev->cnf.rtr_solicit_delay ? : 1);
@@ -2368,7 +2368,7 @@
 	ifm = NLMSG_DATA(nlh);
 	ifm->ifa_family = AF_INET6;
 	ifm->ifa_prefixlen = ifa->prefix_len;
-	ifm->ifa_flags = ifa->flags;
+	ifm->ifa_flags = ifa->flags | ifa->idev->if_flags;
 	ifm->ifa_scope = RT_SCOPE_UNIVERSE;
 	if (ifa->scope&IFA_HOST)
 		ifm->ifa_scope = RT_SCOPE_HOST;
diff -ruN linux-2.5.73.org/net/ipv6/ndisc.c test/linux-2.5.73/net/ipv6/ndisc.c
--- linux-2.5.73.org/net/ipv6/ndisc.c	2003-06-22 11:32:56.000000000 -0700
+++ test/linux-2.5.73/net/ipv6/ndisc.c	2003-07-14 15:06:14.000000000 -0700
@@ -1036,6 +1036,16 @@
 		 */
 		in6_dev->if_flags |= IF_RA_RCVD;
 	}
+	/*
+	 * Remember the managed/otherconf flags from most recently
+	 * receieved RA message (RFC 2462) -- yoshfuji
+	 */
+	in6_dev->if_flags = (in6_dev->if_flags & ~(IF_RA_MANAGED|
+				IF_RA_OTHERCONF)) |
+				(ra_msg->icmph.icmp6_addrconf_managed ?
+					IF_RA_MANAGED : 0) |
+				(ra_msg->icmph.icmp6_addrconf_other ?
+					IF_RA_OTHERCONF : 0);

 	lifetime = ntohs(ra_msg->icmph.icmp6_rt_lifetime);

diff -ruN linux-2.5.73.org/net/ipv6/route.c test/linux-2.5.73/net/ipv6/route.c
--- linux-2.5.73.org/net/ipv6/route.c	2003-06-22 11:33:05.000000000 -0700
+++ test/linux-2.5.73/net/ipv6/route.c	2003-07-16 10:42:01.000000000 -0700
@@ -1400,13 +1400,20 @@
 			 struct in6_addr *src,
 			 int iif,
 			 int type, u32 pid, u32 seq,
-			 struct nlmsghdr *in_nlh)
+			 struct nlmsghdr *in_nlh, int prefix)
 {
 	struct rtmsg *rtm;
 	struct nlmsghdr  *nlh;
 	unsigned char	 *b = skb->tail;
 	struct rta_cacheinfo ci;

+	if (prefix) {	/* user wants prefix routes only */
+		if (!(rt->rt6i_flags & RTF_PREFIX_RT)) {
+			/* success since this is not a prefix route */
+			return 1;
+		}
+	}
+
 	if (!pid && in_nlh) {
 		pid = in_nlh->nlmsg_pid;
 	}
@@ -1487,10 +1494,16 @@
 static int rt6_dump_route(struct rt6_info *rt, void *p_arg)
 {
 	struct rt6_rtnl_dump_arg *arg = (struct rt6_rtnl_dump_arg *) p_arg;
+	struct rtmsg *rtm;
+	int prefix;

+	rtm = NLMSG_DATA(arg->cb->nlh);
+	if (rtm)
+		prefix = (rtm->rtm_flags & RTM_F_PREFIX) != 0;
+	else prefix = 0;
 	return rt6_fill_node(arg->skb, rt, NULL, NULL, 0, RTM_NEWROUTE,
 		     NETLINK_CB(arg->cb->skb).pid, arg->cb->nlh->nlmsg_seq,
-		     NULL);
+		     NULL, prefix);
 }

 static int fib6_dump_node(struct fib6_walker_t *w)
@@ -1638,7 +1651,7 @@
 			    &fl.fl6_dst, &fl.fl6_src,
 			    iif,
 			    RTM_NEWROUTE, NETLINK_CB(in_skb).pid,
-			    nlh->nlmsg_seq, nlh);
+			    nlh->nlmsg_seq, nlh, 0);
 	if (err < 0) {
 		err = -EMSGSIZE;
 		goto out_free;
@@ -1664,7 +1677,7 @@
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_ROUTE, ENOBUFS);
 		return;
 	}
-	if (rt6_fill_node(skb, rt, NULL, NULL, 0, event, 0, 0, nlh) < 0) {
+	if (rt6_fill_node(skb, rt, NULL, NULL, 0, event, 0, 0, nlh, 0) < 0) {
 		kfree_skb(skb);
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_ROUTE, EINVAL);
 		return;

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [PATCH 2/2] Prefix List against 2.4.21
  2003-07-16 18:42         ` [PATCH 1/2] " Krishna Kumar
  2003-07-16 18:49           ` Krishna Kumar
@ 2003-07-16 18:50           ` Krishna Kumar
  1 sibling, 0 replies; 52+ messages in thread
From: Krishna Kumar @ 2003-07-16 18:50 UTC (permalink / raw)
  To: YOSHIFUJI Hideaki / 吉藤英明
  Cc: kuznet, davem, netdev, linux-net

This is the same patch against 2.4.21

Thanks,

- KK

diff -ruN linux-2.4.21.org/include/linux/ipv6_route.h test/linux.2.4.21/include/linux/ipv6_route.h
--- linux-2.4.21.org/include/linux/ipv6_route.h	1998-08-27 19:33:08.000000000 -0700
+++ test/linux.2.4.21/include/linux/ipv6_route.h	2003-07-16 10:58:57.000000000 -0700
@@ -25,6 +25,7 @@
 #define RTF_DEFAULT	0x00010000	/* default - learned via ND	*/
 #define RTF_ALLONLINK	0x00020000	/* fallback, no routers on link	*/
 #define RTF_ADDRCONF	0x00040000	/* addrconf route - RA		*/
+#define RTF_PREFIX_RT	0x00080000	/* A prefix only route - RA	*/

 #define RTF_NONEXTHOP	0x00200000	/* route with no nexthop	*/
 #define RTF_EXPIRES	0x00400000
diff -ruN linux-2.4.21.org/include/linux/rtnetlink.h test/linux.2.4.21/include/linux/rtnetlink.h
--- linux-2.4.21.org/include/linux/rtnetlink.h	2002-11-28 15:53:15.000000000 -0800
+++ test/linux.2.4.21/include/linux/rtnetlink.h	2003-07-16 10:57:58.000000000 -0700
@@ -167,6 +167,7 @@
 #define RTM_F_NOTIFY		0x100	/* Notify user of route change	*/
 #define RTM_F_CLONED		0x200	/* This route is cloned		*/
 #define RTM_F_EQUALIZE		0x400	/* Multipath equalizer: NI	*/
+#define RTM_F_PREFIX		0x800	/* Prefix addresses		*/

 /* Reserved table identifiers */

@@ -198,7 +199,7 @@
 	RTA_MULTIPATH,
 	RTA_PROTOINFO,
 	RTA_FLOW,
-	RTA_CACHEINFO
+	RTA_CACHEINFO,
 };

 #define RTA_MAX RTA_CACHEINFO
diff -ruN linux-2.4.21.org/include/net/if_inet6.h test/linux.2.4.21/include/net/if_inet6.h
--- linux-2.4.21.org/include/net/if_inet6.h	2003-06-13 07:51:39.000000000 -0700
+++ test/linux.2.4.21/include/net/if_inet6.h	2003-07-16 10:54:53.000000000 -0700
@@ -15,7 +15,9 @@
 #ifndef _NET_IF_INET6_H
 #define _NET_IF_INET6_H

-#define IF_RA_RCVD	0x20
+#define IF_RA_OTHERCONF	0x02
+#define IF_RA_MANAGED	0x04
+#define IF_RA_RCVD	0x08
 #define IF_RS_SENT	0x10

 #ifdef __KERNEL__
diff -ruN linux-2.4.21.org/net/ipv6/addrconf.c test/linux.2.4.21/net/ipv6/addrconf.c
--- linux-2.4.21.org/net/ipv6/addrconf.c	2003-06-13 07:51:39.000000000 -0700
+++ test/linux.2.4.21/net/ipv6/addrconf.c	2003-07-16 11:05:15.000000000 -0700
@@ -101,7 +101,7 @@

 static int addrconf_ifdown(struct net_device *dev, int how);

-static void addrconf_dad_start(struct inet6_ifaddr *ifp);
+static void addrconf_dad_start(struct inet6_ifaddr *ifp, int flags);
 static void addrconf_dad_timer(unsigned long data);
 static void addrconf_dad_completed(struct inet6_ifaddr *ifp);
 static void addrconf_rs_timer(unsigned long data);
@@ -889,7 +889,7 @@
 	rtmsg.rtmsg_dst_len = 8;
 	rtmsg.rtmsg_metric = IP6_RT_PRIO_ADDRCONF;
 	rtmsg.rtmsg_ifindex = dev->ifindex;
-	rtmsg.rtmsg_flags = RTF_UP|RTF_ADDRCONF;
+	rtmsg.rtmsg_flags = RTF_UP;
 	rtmsg.rtmsg_type = RTMSG_NEWROUTE;
 	ip6_route_add(&rtmsg, NULL);
 }
@@ -916,7 +916,7 @@
 	struct in6_addr addr;

 	ipv6_addr_set(&addr,  htonl(0xFE800000), 0, 0, 0);
-	addrconf_prefix_route(&addr, 64, dev, 0, RTF_ADDRCONF);
+	addrconf_prefix_route(&addr, 64, dev, 0, 0);
 }

 static struct inet6_dev *addrconf_add_dev(struct net_device *dev)
@@ -1008,7 +1008,8 @@
 		}
 	} else if (pinfo->onlink && valid_lft) {
 		addrconf_prefix_route(&pinfo->prefix, pinfo->prefix_len,
-				      dev, rt_expires, RTF_ADDRCONF|RTF_EXPIRES);
+				      dev, rt_expires,
+				      RTF_ADDRCONF|RTF_EXPIRES|RTF_PREFIX_RT);
 	}
 	if (rt)
 		dst_release(&rt->u.dst);
@@ -1054,7 +1055,7 @@
 				return;
 			}

-			addrconf_dad_start(ifp);
+			addrconf_dad_start(ifp, RTF_ADDRCONF|RTF_PREFIX_RT);
 		}

 		if (ifp && valid_lft == 0) {
@@ -1166,7 +1167,7 @@

 	ifp = ipv6_add_addr(idev, pfx, plen, scope, IFA_F_PERMANENT);
 	if (!IS_ERR(ifp)) {
-		addrconf_dad_start(ifp);
+		addrconf_dad_start(ifp, 0);
 		in6_ifa_put(ifp);
 		return 0;
 	}
@@ -1341,7 +1342,7 @@

 	ifp = ipv6_add_addr(idev, addr, 64, IFA_LINK, IFA_F_PERMANENT);
 	if (!IS_ERR(ifp)) {
-		addrconf_dad_start(ifp);
+		addrconf_dad_start(ifp, 0);
 		in6_ifa_put(ifp);
 	}
 }
@@ -1578,8 +1579,7 @@
 		memset(&rtmsg, 0, sizeof(struct in6_rtmsg));
 		rtmsg.rtmsg_type = RTMSG_NEWROUTE;
 		rtmsg.rtmsg_metric = IP6_RT_PRIO_ADDRCONF;
-		rtmsg.rtmsg_flags = (RTF_ALLONLINK | RTF_ADDRCONF |
-				     RTF_DEFAULT | RTF_UP);
+		rtmsg.rtmsg_flags = (RTF_ALLONLINK | RTF_DEFAULT | RTF_UP);

 		rtmsg.rtmsg_ifindex = ifp->idev->dev->ifindex;

@@ -1593,7 +1593,7 @@
 /*
  *	Duplicate Address Detection
  */
-static void addrconf_dad_start(struct inet6_ifaddr *ifp)
+static void addrconf_dad_start(struct inet6_ifaddr *ifp, int flags)
 {
 	struct net_device *dev;
 	unsigned long rand_num;
@@ -1603,7 +1603,7 @@
 	addrconf_join_solict(dev, &ifp->addr);

 	if (ifp->prefix_len != 128 && (ifp->flags&IFA_F_PERMANENT))
-		addrconf_prefix_route(&ifp->addr, ifp->prefix_len, dev, 0, RTF_ADDRCONF);
+		addrconf_prefix_route(&ifp->addr, ifp->prefix_len, dev, 0, flags);

 	net_srandom(ifp->addr.s6_addr32[3]);
 	rand_num = net_random() % (ifp->idev->cnf.rtr_solicit_delay ? : 1);
@@ -1888,7 +1888,7 @@
 	ifm = NLMSG_DATA(nlh);
 	ifm->ifa_family = AF_INET6;
 	ifm->ifa_prefixlen = ifa->prefix_len;
-	ifm->ifa_flags = ifa->flags;
+	ifm->ifa_flags = ifa->flags | ifa->idev->if_flags;
 	ifm->ifa_scope = RT_SCOPE_UNIVERSE;
 	if (ifa->scope&IFA_HOST)
 		ifm->ifa_scope = RT_SCOPE_HOST;
diff -ruN linux-2.4.21.org/net/ipv6/ndisc.c test/linux.2.4.21/net/ipv6/ndisc.c
--- linux-2.4.21.org/net/ipv6/ndisc.c	2003-06-13 07:51:39.000000000 -0700
+++ test/linux.2.4.21/net/ipv6/ndisc.c	2003-07-14 15:09:28.000000000 -0700
@@ -940,6 +940,16 @@
 		 */
 		in6_dev->if_flags |= IF_RA_RCVD;
 	}
+	/*
+	 * Remember the managed/otherconf flags from most recently
+	 * receieved RA message (RFC 2462) -- yoshfuji
+	 */
+	in6_dev->if_flags = (in6_dev->if_flags & ~(IF_RA_MANAGED|
+				IF_RA_OTHERCONF)) |
+				(ra_msg->icmph.icmp6_addrconf_managed ?
+					IF_RA_MANAGED : 0) |
+				(ra_msg->icmph.icmp6_addrconf_other ?
+					IF_RA_OTHERCONF : 0);

 	lifetime = ntohs(ra_msg->icmph.icmp6_rt_lifetime);

diff -ruN linux-2.4.21.org/net/ipv6/route.c test/linux.2.4.21/net/ipv6/route.c
--- linux-2.4.21.org/net/ipv6/route.c	2003-06-13 07:51:39.000000000 -0700
+++ test/linux.2.4.21/net/ipv6/route.c	2003-07-16 11:09:45.000000000 -0700
@@ -1516,13 +1516,20 @@
 			 struct in6_addr *src,
 			 int iif,
 			 int type, u32 pid, u32 seq,
-			 struct nlmsghdr *in_nlh)
+			 struct nlmsghdr *in_nlh, int prefix)
 {
 	struct rtmsg *rtm;
 	struct nlmsghdr  *nlh;
 	unsigned char	 *b = skb->tail;
 	struct rta_cacheinfo ci;

+	if (prefix) {	/* user wants prefix routes only */
+		if (!(rt->rt6i_flags & RTF_PREFIX_RT)) {
+			/* success since this is not a prefix route */
+			return 1;
+		}
+	}
+
 	if (!pid && in_nlh) {
 		pid = in_nlh->nlmsg_pid;
 	}
@@ -1603,10 +1610,16 @@
 static int rt6_dump_route(struct rt6_info *rt, void *p_arg)
 {
 	struct rt6_rtnl_dump_arg *arg = (struct rt6_rtnl_dump_arg *) p_arg;
+	struct rtmsg *rtm;
+	int prefix;

+	rtm = NLMSG_DATA(arg->cb->nlh);
+	if (rtm)
+		prefix = (rtm->rtm_flags & RTM_F_PREFIX) != 0;
+	else prefix = 0;
 	return rt6_fill_node(arg->skb, rt, NULL, NULL, 0, RTM_NEWROUTE,
 		     NETLINK_CB(arg->cb->skb).pid, arg->cb->nlh->nlmsg_seq,
-		     NULL);
+		     NULL, prefix);
 }

 static int fib6_dump_node(struct fib6_walker_t *w)
@@ -1757,7 +1770,7 @@
 			    fl.nl_u.ip6_u.saddr,
 			    iif,
 			    RTM_NEWROUTE, NETLINK_CB(in_skb).pid,
-			    nlh->nlmsg_seq, nlh);
+			    nlh->nlmsg_seq, nlh, 0);
 	if (err < 0) {
 		err = -EMSGSIZE;
 		goto out_free;
@@ -1783,7 +1796,7 @@
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_ROUTE, ENOBUFS);
 		return;
 	}
-	if (rt6_fill_node(skb, rt, NULL, NULL, 0, event, 0, 0, nlh) < 0) {
+	if (rt6_fill_node(skb, rt, NULL, NULL, 0, event, 0, 0, nlh, 0) < 0) {
 		kfree_skb(skb);
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_ROUTE, EINVAL);
 		return;

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 1/4] Prefix List against 2.5.73
  2003-07-16  8:39       ` YOSHIFUJI Hideaki / 吉藤英明
  2003-07-16 18:42         ` [PATCH 1/2] " Krishna Kumar
@ 2003-07-16 23:41         ` kuznet
  2003-07-17  0:06           ` Krishna Kumar
  1 sibling, 1 reply; 52+ messages in thread
From: kuznet @ 2003-07-16 23:41 UTC (permalink / raw)
  To: YOSHIFUJIHideaki/吉藤英明
  Cc: krkumar, davem, netdev, yoshfuji, linux-net

Hello!

> My suggestion is:
>  - create L3 per-interface RTM, say, RTM_xxxIFACE.
>  - provide inet_device / inet6_dev things via this RTM.
>     e.g. per-interface statistics, flags etc.

I agree for all 100%. I understand your attitude now.

Alexey

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 1/4] Prefix List against 2.5.73
  2003-07-16 23:41         ` [PATCH 1/4] Prefix List against 2.5.73 kuznet
@ 2003-07-17  0:06           ` Krishna Kumar
  2003-07-17  0:38             ` kuznet
  0 siblings, 1 reply; 52+ messages in thread
From: Krishna Kumar @ 2003-07-17  0:06 UTC (permalink / raw)
  To: kuznet; +Cc: yoshfuji, davem, netdev, linux-net

This is sort of what I had originally, so I should be able to change
it to do this quite easily. I didn't like the earlier suggestion of
using existing RTM_xxxLINK with RTM_xxxIFACE (since it was dev generic),
but having a new interface RTM_xxxIFACE sounds good to me.

Thanks,

- KK

kuznet@ms2.inr.ac.ru wrote:
> Hello!
> 
> 
>>My suggestion is:
>> - create L3 per-interface RTM, say, RTM_xxxIFACE.
>> - provide inet_device / inet6_dev things via this RTM.
>>    e.g. per-interface statistics, flags etc.
> 
> 
> I agree for all 100%. I understand your attitude now.
> 
> Alexey
> 


^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 1/4] Prefix List against 2.5.73
  2003-07-17  0:06           ` Krishna Kumar
@ 2003-07-17  0:38             ` kuznet
  2003-07-17 21:12               ` [PATCH 1/2] Prefix List and O/M flags " Krishna Kumar
  2003-07-17 21:53               ` [PATCH 1/4] Prefix List against 2.5.73 YOSHIFUJI Hideaki / 吉藤英明
  0 siblings, 2 replies; 52+ messages in thread
From: kuznet @ 2003-07-17  0:38 UTC (permalink / raw)
  To: Krishna Kumar; +Cc: yoshfuji, davem, netdev, linux-net

Hello!

> This is sort of what I had originally, so I should be able to change
> it to do this quite easily. I didn't like the earlier suggestion of
> using existing RTM_xxxLINK with RTM_xxxIFACE (since it was dev generic),
> but having a new interface RTM_xxxIFACE sounds good to me.

Actually, the original plan was to use ifli_family to query something
or to direct a request to a specific interface on some netdevice.
I wanted to reserve IFLI_PROTINFO attribute to encapsulate information
private for specific family. It was not realized mostly because of absense
of such information.

Maybe, you will want to resurrect this.

Alexey

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [PATCH 1/2] Prefix List and O/M flags against 2.5.73
  2003-07-17  0:38             ` kuznet
@ 2003-07-17 21:12               ` Krishna Kumar
  2003-07-17 22:06                 ` [PATCH 2/2] Prefix List and O/M flags against 2.4.21 Krishna Kumar
  2003-07-17 21:53               ` [PATCH 1/4] Prefix List against 2.5.73 YOSHIFUJI Hideaki / 吉藤英明
  1 sibling, 1 reply; 52+ messages in thread
From: Krishna Kumar @ 2003-07-17 21:12 UTC (permalink / raw)
  To: kuznet; +Cc: yoshfuji, davem, netdev, linux-net


> > This is sort of what I had originally, so I should be able to change
> > it to do this quite easily. I didn't like the earlier suggestion of
> > using existing RTM_xxxLINK with RTM_xxxIFACE (since it was dev
generic),
> > but having a new interface RTM_xxxIFACE sounds good to me.

> Actually, the original plan was to use ifli_family to query something
> or to direct a request to a specific interface on some netdevice.
> I wanted to reserve IFLI_PROTINFO attribute to encapsulate information
> private for specific family. It was not realized mostly because of
absense
> of such information.
>
> Maybe, you will want to resurrect this.

I am sorry, but I have no idea what you are talking about :-)

I am including patch with what was agreed upon yesterday by everyone. I
have tested the prefix list retrieval by using ip (with slight changes to
ip command,now I can dump prefix by "ip -f inet6 route prefix", with
identical format to "ip -f inet6 route" command). For the O/M flags,  I am
using a new RTM_GETIFFLAGS but if needed this can be changed to use
RTM_GETLNKINFO (or something) with RTA_IFFLAGS, if multiple data needs to
be returned. If that is needed, I can submit a (5 line?) patch to be
applied after this is accepted..

Thanks,

- KK

diff -ruN linux-2.5.73.org/include/linux/ipv6_route.h test/linux-2.5.73/include/linux/ipv6_route.h
--- linux-2.5.73.org/include/linux/ipv6_route.h	2003-06-22 11:32:36.000000000 -0700
+++ test/linux-2.5.73/include/linux/ipv6_route.h	2003-07-17 11:38:23.000000000 -0700
@@ -16,6 +16,7 @@
 #define RTF_DEFAULT	0x00010000	/* default - learned via ND	*/
 #define RTF_ALLONLINK	0x00020000	/* fallback, no routers on link	*/
 #define RTF_ADDRCONF	0x00040000	/* addrconf route - RA		*/
+#define RTF_PREFIX_RT	0x00080000	/* A prefix only route - RA	*/

 #define RTF_NONEXTHOP	0x00200000	/* route with no nexthop	*/
 #define RTF_EXPIRES	0x00400000
diff -ruN linux-2.5.73.org/include/linux/rtnetlink.h test/linux-2.5.73/include/linux/rtnetlink.h
--- linux-2.5.73.org/include/linux/rtnetlink.h	2003-06-22 11:33:07.000000000 -0700
+++ test/linux-2.5.73/include/linux/rtnetlink.h	2003-07-16 17:23:06.000000000 -0700
@@ -47,7 +47,9 @@
 #define	RTM_DELTFILTER	(RTM_BASE+29)
 #define	RTM_GETTFILTER	(RTM_BASE+30)

-#define	RTM_MAX		(RTM_BASE+31)
+#define	RTM_GETIFFLAGS	(RTM_BASE+34)
+
+#define	RTM_MAX		(RTM_GETIFFLAGS+1)

 /*
    Generic structure for encapsulation of optional route information.
@@ -61,6 +63,13 @@
 	unsigned short	rta_type;
 };

+/* Structure to return per interface device flags */
+struct ifp_if6info
+{
+	int ifindex;
+	int flags;
+};
+
 /* Macros to handle rtattributes */

 #define RTA_ALIGNTO	4
@@ -168,6 +177,7 @@
 #define RTM_F_NOTIFY		0x100	/* Notify user of route change	*/
 #define RTM_F_CLONED		0x200	/* This route is cloned		*/
 #define RTM_F_EQUALIZE		0x400	/* Multipath equalizer: NI	*/
+#define RTM_F_PREFIX		0x800	/* Prefix addresses		*/

 /* Reserved table identifiers */

diff -ruN linux-2.5.73.org/include/net/if_inet6.h test/linux-2.5.73/include/net/if_inet6.h
--- linux-2.5.73.org/include/net/if_inet6.h	2003-06-22 11:33:32.000000000 -0700
+++ test/linux-2.5.73/include/net/if_inet6.h	2003-07-16 17:23:24.000000000 -0700
@@ -17,6 +17,8 @@

 #include <net/snmp.h>

+#define IF_RA_OTHERCONF	0x80
+#define IF_RA_MANAGED	0x40
 #define IF_RA_RCVD	0x20
 #define IF_RS_SENT	0x10

diff -ruN linux-2.5.73.org/net/ipv6/addrconf.c test/linux-2.5.73/net/ipv6/addrconf.c
--- linux-2.5.73.org/net/ipv6/addrconf.c	2003-06-22 11:33:17.000000000 -0700
+++ test/linux-2.5.73/net/ipv6/addrconf.c	2003-07-17 11:40:48.000000000 -0700
@@ -129,7 +129,7 @@

 static int addrconf_ifdown(struct net_device *dev, int how);

-static void addrconf_dad_start(struct inet6_ifaddr *ifp);
+static void addrconf_dad_start(struct inet6_ifaddr *ifp, int flags);
 static void addrconf_dad_timer(unsigned long data);
 static void addrconf_dad_completed(struct inet6_ifaddr *ifp);
 static void addrconf_rs_timer(unsigned long data);
@@ -715,7 +715,7 @@
 	ift->prefered_lft = tmp_prefered_lft;
 	ift->tstamp = ifp->tstamp;
 	spin_unlock_bh(&ift->lock);
-	addrconf_dad_start(ift);
+	addrconf_dad_start(ift, 0);
 	in6_ifa_put(ift);
 	in6_dev_put(idev);
 out:
@@ -1211,7 +1211,7 @@
 	rtmsg.rtmsg_dst_len = 8;
 	rtmsg.rtmsg_metric = IP6_RT_PRIO_ADDRCONF;
 	rtmsg.rtmsg_ifindex = dev->ifindex;
-	rtmsg.rtmsg_flags = RTF_UP|RTF_ADDRCONF;
+	rtmsg.rtmsg_flags = RTF_UP;
 	rtmsg.rtmsg_type = RTMSG_NEWROUTE;
 	ip6_route_add(&rtmsg, NULL, NULL);
 }
@@ -1238,7 +1238,7 @@
 	struct in6_addr addr;

 	ipv6_addr_set(&addr,  htonl(0xFE800000), 0, 0, 0);
-	addrconf_prefix_route(&addr, 64, dev, 0, RTF_ADDRCONF);
+	addrconf_prefix_route(&addr, 64, dev, 0, 0);
 }

 static struct inet6_dev *addrconf_add_dev(struct net_device *dev)
@@ -1330,7 +1330,8 @@
 		}
 	} else if (pinfo->onlink && valid_lft) {
 		addrconf_prefix_route(&pinfo->prefix, pinfo->prefix_len,
-				      dev, rt_expires, RTF_ADDRCONF|RTF_EXPIRES);
+				      dev, rt_expires,
+				      RTF_ADDRCONF|RTF_EXPIRES|RTF_PREFIX_RT);
 	}
 	if (rt)
 		dst_release(&rt->u.dst);
@@ -1378,7 +1379,7 @@
 			}

 			create = 1;
-			addrconf_dad_start(ifp);
+			addrconf_dad_start(ifp, RTF_ADDRCONF|RTF_PREFIX_RT);
 		}

 		if (ifp && valid_lft == 0) {
@@ -1529,7 +1530,7 @@

 	ifp = ipv6_add_addr(idev, pfx, plen, scope, IFA_F_PERMANENT);
 	if (!IS_ERR(ifp)) {
-		addrconf_dad_start(ifp);
+		addrconf_dad_start(ifp, 0);
 		in6_ifa_put(ifp);
 		return 0;
 	}
@@ -1704,7 +1705,7 @@

 	ifp = ipv6_add_addr(idev, addr, 64, IFA_LINK, IFA_F_PERMANENT);
 	if (!IS_ERR(ifp)) {
-		addrconf_dad_start(ifp);
+		addrconf_dad_start(ifp, 0);
 		in6_ifa_put(ifp);
 	}
 }
@@ -1943,8 +1944,7 @@
 		memset(&rtmsg, 0, sizeof(struct in6_rtmsg));
 		rtmsg.rtmsg_type = RTMSG_NEWROUTE;
 		rtmsg.rtmsg_metric = IP6_RT_PRIO_ADDRCONF;
-		rtmsg.rtmsg_flags = (RTF_ALLONLINK | RTF_ADDRCONF |
-				     RTF_DEFAULT | RTF_UP);
+		rtmsg.rtmsg_flags = (RTF_ALLONLINK | RTF_DEFAULT | RTF_UP);

 		rtmsg.rtmsg_ifindex = ifp->idev->dev->ifindex;

@@ -1958,7 +1958,7 @@
 /*
  *	Duplicate Address Detection
  */
-static void addrconf_dad_start(struct inet6_ifaddr *ifp)
+static void addrconf_dad_start(struct inet6_ifaddr *ifp, int flags)
 {
 	struct net_device *dev;
 	unsigned long rand_num;
@@ -1968,7 +1968,7 @@
 	addrconf_join_solict(dev, &ifp->addr);

 	if (ifp->prefix_len != 128 && (ifp->flags&IFA_F_PERMANENT))
-		addrconf_prefix_route(&ifp->addr, ifp->prefix_len, dev, 0, RTF_ADDRCONF);
+		addrconf_prefix_route(&ifp->addr, ifp->prefix_len, dev, 0, flags);

 	net_srandom(ifp->addr.s6_addr32[3]);
 	rand_num = net_random() % (ifp->idev->cnf.rtr_solicit_delay ? : 1);
@@ -2451,6 +2451,42 @@
 	netlink_broadcast(rtnl, skb, 0, RTMGRP_IPV6_IFADDR, GFP_ATOMIC);
 }

+int inet6_dump_linkflags(struct sk_buff *skb, struct netlink_callback *cb)
+{
+	int ifindex, flags;
+	struct net_device *dev;
+	struct inet6_dev *idev;
+	struct nlmsghdr *nlh;
+	struct ifp_if6info *ifp = NLMSG_DATA(cb->nlh);
+	unsigned char *org_tail = skb->tail;
+
+	ifindex = ifp->ifindex;
+	if ((dev = dev_get_by_index(ifindex)) == NULL)
+		goto out;
+	if ((idev = in6_dev_get(dev)) != NULL) {
+		flags = idev->if_flags;
+		in6_dev_put(idev);
+	} else
+		flags = 0;
+	dev_put(dev);
+
+	nlh = NLMSG_PUT(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq,
+			RTM_GETIFFLAGS, sizeof(*ifp));
+	ifp = NLMSG_DATA(nlh);
+	ifp->flags = flags;
+	ifp->ifindex = ifindex;    /* duplicate info for user to verify */
+
+	nlh->nlmsg_len = skb->tail - org_tail;
+	return skb->len;
+
+nlmsg_failure:
+	printk(KERN_INFO "inet6_dump_linkflags:skb size not enough\n");
+	skb_trim(skb, org_tail - skb->data);
+
+out:
+	return -1;
+}
+
 static struct rtnetlink_link inet6_rtnetlink_table[RTM_MAX - RTM_BASE + 1] = {
 	[RTM_NEWADDR - RTM_BASE] = { .doit	= inet6_rtm_newaddr, },
 	[RTM_DELADDR - RTM_BASE] = { .doit	= inet6_rtm_deladdr, },
@@ -2459,6 +2495,7 @@
 	[RTM_DELROUTE - RTM_BASE] = { .doit	= inet6_rtm_delroute, },
 	[RTM_GETROUTE - RTM_BASE] = { .doit	= inet6_rtm_getroute,
 				      .dumpit	= inet6_dump_fib, },
+	[RTM_GETIFFLAGS - RTM_BASE] = {.dumpit	= inet6_dump_linkflags, },
 };

 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
diff -ruN linux-2.5.73.org/net/ipv6/ndisc.c test/linux-2.5.73/net/ipv6/ndisc.c
--- linux-2.5.73.org/net/ipv6/ndisc.c	2003-06-22 11:32:56.000000000 -0700
+++ test/linux-2.5.73/net/ipv6/ndisc.c	2003-07-14 15:06:14.000000000 -0700
@@ -1036,6 +1036,16 @@
 		 */
 		in6_dev->if_flags |= IF_RA_RCVD;
 	}
+	/*
+	 * Remember the managed/otherconf flags from most recently
+	 * receieved RA message (RFC 2462) -- yoshfuji
+	 */
+	in6_dev->if_flags = (in6_dev->if_flags & ~(IF_RA_MANAGED|
+				IF_RA_OTHERCONF)) |
+				(ra_msg->icmph.icmp6_addrconf_managed ?
+					IF_RA_MANAGED : 0) |
+				(ra_msg->icmph.icmp6_addrconf_other ?
+					IF_RA_OTHERCONF : 0);

 	lifetime = ntohs(ra_msg->icmph.icmp6_rt_lifetime);

diff -ruN linux-2.5.73.org/net/ipv6/route.c test/linux-2.5.73/net/ipv6/route.c
--- linux-2.5.73.org/net/ipv6/route.c	2003-06-22 11:33:05.000000000 -0700
+++ test/linux-2.5.73/net/ipv6/route.c	2003-07-16 10:42:01.000000000 -0700
@@ -1400,13 +1400,20 @@
 			 struct in6_addr *src,
 			 int iif,
 			 int type, u32 pid, u32 seq,
-			 struct nlmsghdr *in_nlh)
+			 struct nlmsghdr *in_nlh, int prefix)
 {
 	struct rtmsg *rtm;
 	struct nlmsghdr  *nlh;
 	unsigned char	 *b = skb->tail;
 	struct rta_cacheinfo ci;

+	if (prefix) {	/* user wants prefix routes only */
+		if (!(rt->rt6i_flags & RTF_PREFIX_RT)) {
+			/* success since this is not a prefix route */
+			return 1;
+		}
+	}
+
 	if (!pid && in_nlh) {
 		pid = in_nlh->nlmsg_pid;
 	}
@@ -1487,10 +1494,16 @@
 static int rt6_dump_route(struct rt6_info *rt, void *p_arg)
 {
 	struct rt6_rtnl_dump_arg *arg = (struct rt6_rtnl_dump_arg *) p_arg;
+	struct rtmsg *rtm;
+	int prefix;

+	rtm = NLMSG_DATA(arg->cb->nlh);
+	if (rtm)
+		prefix = (rtm->rtm_flags & RTM_F_PREFIX) != 0;
+	else prefix = 0;
 	return rt6_fill_node(arg->skb, rt, NULL, NULL, 0, RTM_NEWROUTE,
 		     NETLINK_CB(arg->cb->skb).pid, arg->cb->nlh->nlmsg_seq,
-		     NULL);
+		     NULL, prefix);
 }

 static int fib6_dump_node(struct fib6_walker_t *w)
@@ -1638,7 +1651,7 @@
 			    &fl.fl6_dst, &fl.fl6_src,
 			    iif,
 			    RTM_NEWROUTE, NETLINK_CB(in_skb).pid,
-			    nlh->nlmsg_seq, nlh);
+			    nlh->nlmsg_seq, nlh, 0);
 	if (err < 0) {
 		err = -EMSGSIZE;
 		goto out_free;
@@ -1664,7 +1677,7 @@
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_ROUTE, ENOBUFS);
 		return;
 	}
-	if (rt6_fill_node(skb, rt, NULL, NULL, 0, event, 0, 0, nlh) < 0) {
+	if (rt6_fill_node(skb, rt, NULL, NULL, 0, event, 0, 0, nlh, 0) < 0) {
 		kfree_skb(skb);
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_ROUTE, EINVAL);
 		return;

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 1/4] Prefix List against 2.5.73
  2003-07-17  0:38             ` kuznet
  2003-07-17 21:12               ` [PATCH 1/2] Prefix List and O/M flags " Krishna Kumar
@ 2003-07-17 21:53               ` YOSHIFUJI Hideaki / 吉藤英明
  1 sibling, 0 replies; 52+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2003-07-17 21:53 UTC (permalink / raw)
  To: kuznet; +Cc: krkumar, davem, netdev, linux-net, yoshfuji

In article <200307170038.EAA12945@dub.inr.ac.ru> (at Thu, 17 Jul 2003 04:38:00 +0400 (MSD)), kuznet@ms2.inr.ac.ru says:

> Actually, the original plan was to use ifli_family to query something
> or to direct a request to a specific interface on some netdevice.
> I wanted to reserve IFLI_PROTINFO attribute to encapsulate information
> private for specific family. It was not realized mostly because of absense
> of such information.
> 
> Maybe, you will want to resurrect this.

Ah, okay, I'm ok to reuse ifi_family in ifinfomsg{}.
e.g. if ifi_family == AF_INET6 (and/or AF_UNSPEC?), kernel sends 
per-interface IPv6 information.
  IFLA_INET6       provides if_flags (etc?)
  IFLA_INET6_CONF  provides cnf (without proc_dir_entry :-p)
  IFLA_INET6_STATS provides stats (XXX: missing entries in stats)
  IFLA_INET6_MCAST provides mc_XXX things
etc, etc.

sounds reasonable?

-- 
Hideaki YOSHIFUJI @ USAGI Project <yoshfuji@linux-ipv6.org>
GPG FP: 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [PATCH 2/2] Prefix List and O/M flags against 2.4.21
  2003-07-17 21:12               ` [PATCH 1/2] Prefix List and O/M flags " Krishna Kumar
@ 2003-07-17 22:06                 ` Krishna Kumar
  2003-07-17 22:22                   ` YOSHIFUJI Hideaki / 吉藤英明
  0 siblings, 1 reply; 52+ messages in thread
From: Krishna Kumar @ 2003-07-17 22:06 UTC (permalink / raw)
  To: kuznet; +Cc: yoshfuji, davem, netdev, linux-net


The same patch against 2.4.21

Thanks,

- KK

diff -ruN linux-2.4.21.org/include/linux/ipv6_route.h test/linux.2.4.21/include/linux/ipv6_route.h
--- linux-2.4.21.org/include/linux/ipv6_route.h	1998-08-27 19:33:08.000000000 -0700
+++ test/linux.2.4.21/include/linux/ipv6_route.h	2003-07-17 11:42:17.000000000 -0700
@@ -25,6 +25,7 @@
 #define RTF_DEFAULT	0x00010000	/* default - learned via ND	*/
 #define RTF_ALLONLINK	0x00020000	/* fallback, no routers on link	*/
 #define RTF_ADDRCONF	0x00040000	/* addrconf route - RA		*/
+#define RTF_PREFIX_RT	0x00080000	/* A prefix only route - RA	*/

 #define RTF_NONEXTHOP	0x00200000	/* route with no nexthop	*/
 #define RTF_EXPIRES	0x00400000
diff -ruN linux-2.4.21.org/include/linux/rtnetlink.h test/linux.2.4.21/include/linux/rtnetlink.h
--- linux-2.4.21.org/include/linux/rtnetlink.h	2002-11-28 15:53:15.000000000 -0800
+++ test/linux.2.4.21/include/linux/rtnetlink.h	2003-07-17 13:32:36.000000000 -0700
@@ -46,9 +46,11 @@
 #define	RTM_DELTFILTER	(RTM_BASE+29)
 #define	RTM_GETTFILTER	(RTM_BASE+30)

-#define	RTM_MAX		(RTM_BASE+31)
+#define	RTM_GETIFFLAGS	(RTM_BASE+34)

-/*
+#define	RTM_MAX		(RTM_GETIFFLAGS+1)
+
+/*
    Generic structure for encapsulation optional route information.
    It is reminiscent of sockaddr, but with sa_family replaced
    with attribute type.
@@ -60,6 +62,13 @@
 	unsigned short	rta_type;
 };

+/* Structure to return per interface device flags */
+struct ifp_if6info
+{
+	int ifindex;
+	int flags;
+};
+
 /* Macros to handle rtattributes */

 #define RTA_ALIGNTO	4
@@ -167,6 +176,7 @@
 #define RTM_F_NOTIFY		0x100	/* Notify user of route change	*/
 #define RTM_F_CLONED		0x200	/* This route is cloned		*/
 #define RTM_F_EQUALIZE		0x400	/* Multipath equalizer: NI	*/
+#define RTM_F_PREFIX		0x800	/* Prefix addresses		*/

 /* Reserved table identifiers */

diff -ruN linux-2.4.21.org/include/net/if_inet6.h test/linux.2.4.21/include/net/if_inet6.h
--- linux-2.4.21.org/include/net/if_inet6.h	2003-06-13 07:51:39.000000000 -0700
+++ test/linux.2.4.21/include/net/if_inet6.h	2003-07-17 11:43:50.000000000 -0700
@@ -15,6 +15,8 @@
 #ifndef _NET_IF_INET6_H
 #define _NET_IF_INET6_H

+#define IF_RA_OTHERCONF	0x80
+#define IF_RA_MANAGED	0x40
 #define IF_RA_RCVD	0x20
 #define IF_RS_SENT	0x10

diff -ruN linux-2.4.21.org/net/ipv6/addrconf.c test/linux.2.4.21/net/ipv6/addrconf.c
--- linux-2.4.21.org/net/ipv6/addrconf.c	2003-06-13 07:51:39.000000000 -0700
+++ test/linux.2.4.21/net/ipv6/addrconf.c	2003-07-17 13:34:02.000000000 -0700
@@ -101,7 +101,7 @@

 static int addrconf_ifdown(struct net_device *dev, int how);

-static void addrconf_dad_start(struct inet6_ifaddr *ifp);
+static void addrconf_dad_start(struct inet6_ifaddr *ifp, int flags);
 static void addrconf_dad_timer(unsigned long data);
 static void addrconf_dad_completed(struct inet6_ifaddr *ifp);
 static void addrconf_rs_timer(unsigned long data);
@@ -889,7 +889,7 @@
 	rtmsg.rtmsg_dst_len = 8;
 	rtmsg.rtmsg_metric = IP6_RT_PRIO_ADDRCONF;
 	rtmsg.rtmsg_ifindex = dev->ifindex;
-	rtmsg.rtmsg_flags = RTF_UP|RTF_ADDRCONF;
+	rtmsg.rtmsg_flags = RTF_UP;
 	rtmsg.rtmsg_type = RTMSG_NEWROUTE;
 	ip6_route_add(&rtmsg, NULL);
 }
@@ -916,7 +916,7 @@
 	struct in6_addr addr;

 	ipv6_addr_set(&addr,  htonl(0xFE800000), 0, 0, 0);
-	addrconf_prefix_route(&addr, 64, dev, 0, RTF_ADDRCONF);
+	addrconf_prefix_route(&addr, 64, dev, 0, 0);
 }

 static struct inet6_dev *addrconf_add_dev(struct net_device *dev)
@@ -1008,7 +1008,8 @@
 		}
 	} else if (pinfo->onlink && valid_lft) {
 		addrconf_prefix_route(&pinfo->prefix, pinfo->prefix_len,
-				      dev, rt_expires, RTF_ADDRCONF|RTF_EXPIRES);
+				      dev, rt_expires,
+				      RTF_ADDRCONF|RTF_EXPIRES|RTF_PREFIX_RT);
 	}
 	if (rt)
 		dst_release(&rt->u.dst);
@@ -1054,7 +1055,7 @@
 				return;
 			}

-			addrconf_dad_start(ifp);
+			addrconf_dad_start(ifp, RTF_ADDRCONF|RTF_PREFIX_RT);
 		}

 		if (ifp && valid_lft == 0) {
@@ -1166,7 +1167,7 @@

 	ifp = ipv6_add_addr(idev, pfx, plen, scope, IFA_F_PERMANENT);
 	if (!IS_ERR(ifp)) {
-		addrconf_dad_start(ifp);
+		addrconf_dad_start(ifp, 0);
 		in6_ifa_put(ifp);
 		return 0;
 	}
@@ -1341,7 +1342,7 @@

 	ifp = ipv6_add_addr(idev, addr, 64, IFA_LINK, IFA_F_PERMANENT);
 	if (!IS_ERR(ifp)) {
-		addrconf_dad_start(ifp);
+		addrconf_dad_start(ifp, 0);
 		in6_ifa_put(ifp);
 	}
 }
@@ -1578,8 +1579,7 @@
 		memset(&rtmsg, 0, sizeof(struct in6_rtmsg));
 		rtmsg.rtmsg_type = RTMSG_NEWROUTE;
 		rtmsg.rtmsg_metric = IP6_RT_PRIO_ADDRCONF;
-		rtmsg.rtmsg_flags = (RTF_ALLONLINK | RTF_ADDRCONF |
-				     RTF_DEFAULT | RTF_UP);
+		rtmsg.rtmsg_flags = (RTF_ALLONLINK | RTF_DEFAULT | RTF_UP);

 		rtmsg.rtmsg_ifindex = ifp->idev->dev->ifindex;

@@ -1593,7 +1593,7 @@
 /*
  *	Duplicate Address Detection
  */
-static void addrconf_dad_start(struct inet6_ifaddr *ifp)
+static void addrconf_dad_start(struct inet6_ifaddr *ifp, int flags)
 {
 	struct net_device *dev;
 	unsigned long rand_num;
@@ -1603,7 +1603,7 @@
 	addrconf_join_solict(dev, &ifp->addr);

 	if (ifp->prefix_len != 128 && (ifp->flags&IFA_F_PERMANENT))
-		addrconf_prefix_route(&ifp->addr, ifp->prefix_len, dev, 0, RTF_ADDRCONF);
+		addrconf_prefix_route(&ifp->addr, ifp->prefix_len, dev, 0, flags);

 	net_srandom(ifp->addr.s6_addr32[3]);
 	rand_num = net_random() % (ifp->idev->cnf.rtr_solicit_delay ? : 1);
@@ -1971,6 +1971,42 @@
 	netlink_broadcast(rtnl, skb, 0, RTMGRP_IPV6_IFADDR, GFP_ATOMIC);
 }

+int inet6_dump_linkflags(struct sk_buff *skb, struct netlink_callback *cb)
+{
+	int ifindex, flags;
+	struct net_device *dev;
+	struct inet6_dev *idev;
+	struct nlmsghdr *nlh;
+	struct ifp_if6info *ifp = NLMSG_DATA(cb->nlh);
+	unsigned char *org_tail = skb->tail;
+
+	ifindex = ifp->ifindex;
+	if ((dev = dev_get_by_index(ifindex)) == NULL)
+		goto out;
+	if ((idev = in6_dev_get(dev)) != NULL) {
+		flags = idev->if_flags;
+		in6_dev_put(idev);
+	} else
+		flags = 0;
+	dev_put(dev);
+
+	nlh = NLMSG_PUT(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq,
+			RTM_GETIFFLAGS, sizeof(*ifp));
+	ifp = NLMSG_DATA(nlh);
+	ifp->flags = flags;
+	ifp->ifindex = ifindex;    /* duplicate info for user to verify */
+
+	nlh->nlmsg_len = skb->tail - org_tail;
+	return skb->len;
+
+nlmsg_failure:
+	printk(KERN_INFO "inet6_dump_linkflags:skb size not enough\n");
+	skb_trim(skb, org_tail - skb->data);
+
+out:
+	return -1;
+}
+
 static struct rtnetlink_link inet6_rtnetlink_table[RTM_MAX-RTM_BASE+1] =
 {
 	{ NULL,			NULL,			},
@@ -1987,6 +2023,36 @@
 	{ inet6_rtm_delroute,	NULL,			},
 	{ inet6_rtm_getroute,	inet6_dump_fib,		},
 	{ NULL,			NULL,			},
+
+	{ NULL,			NULL,			},
+	{ NULL,			NULL,			},
+	{ NULL,			NULL,			},
+	{ NULL,			NULL,			},
+
+	{ NULL,			NULL,			},
+	{ NULL,			NULL,			},
+	{ NULL,			NULL,			},
+	{ NULL,			NULL,			},
+
+	{ NULL,			NULL,			},
+	{ NULL,			NULL,			},
+	{ NULL,			NULL,			},
+	{ NULL,			NULL,			},
+
+	{ NULL,			NULL,			},
+	{ NULL,			NULL,			},
+	{ NULL,			NULL,			},
+	{ NULL,			NULL,			},
+
+	{ NULL,			NULL,			},
+	{ NULL,			NULL,			},
+	{ NULL,			NULL,			},
+	{ NULL,			NULL,			},
+
+	{ NULL,			NULL,			},
+	{ NULL,			NULL,			},
+	{ NULL,			inet6_dump_linkflags	},
+	{ NULL,			NULL,			},
 };

 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
diff -ruN linux-2.4.21.org/net/ipv6/ndisc.c test/linux.2.4.21/net/ipv6/ndisc.c
--- linux-2.4.21.org/net/ipv6/ndisc.c	2003-06-13 07:51:39.000000000 -0700
+++ test/linux.2.4.21/net/ipv6/ndisc.c	2003-07-14 15:09:28.000000000 -0700
@@ -940,6 +940,16 @@
 		 */
 		in6_dev->if_flags |= IF_RA_RCVD;
 	}
+	/*
+	 * Remember the managed/otherconf flags from most recently
+	 * receieved RA message (RFC 2462) -- yoshfuji
+	 */
+	in6_dev->if_flags = (in6_dev->if_flags & ~(IF_RA_MANAGED|
+				IF_RA_OTHERCONF)) |
+				(ra_msg->icmph.icmp6_addrconf_managed ?
+					IF_RA_MANAGED : 0) |
+				(ra_msg->icmph.icmp6_addrconf_other ?
+					IF_RA_OTHERCONF : 0);

 	lifetime = ntohs(ra_msg->icmph.icmp6_rt_lifetime);

diff -ruN linux-2.4.21.org/net/ipv6/route.c test/linux.2.4.21/net/ipv6/route.c
--- linux-2.4.21.org/net/ipv6/route.c	2003-06-13 07:51:39.000000000 -0700
+++ test/linux.2.4.21/net/ipv6/route.c	2003-07-16 11:09:45.000000000 -0700
@@ -1516,13 +1516,20 @@
 			 struct in6_addr *src,
 			 int iif,
 			 int type, u32 pid, u32 seq,
-			 struct nlmsghdr *in_nlh)
+			 struct nlmsghdr *in_nlh, int prefix)
 {
 	struct rtmsg *rtm;
 	struct nlmsghdr  *nlh;
 	unsigned char	 *b = skb->tail;
 	struct rta_cacheinfo ci;

+	if (prefix) {	/* user wants prefix routes only */
+		if (!(rt->rt6i_flags & RTF_PREFIX_RT)) {
+			/* success since this is not a prefix route */
+			return 1;
+		}
+	}
+
 	if (!pid && in_nlh) {
 		pid = in_nlh->nlmsg_pid;
 	}
@@ -1603,10 +1610,16 @@
 static int rt6_dump_route(struct rt6_info *rt, void *p_arg)
 {
 	struct rt6_rtnl_dump_arg *arg = (struct rt6_rtnl_dump_arg *) p_arg;
+	struct rtmsg *rtm;
+	int prefix;

+	rtm = NLMSG_DATA(arg->cb->nlh);
+	if (rtm)
+		prefix = (rtm->rtm_flags & RTM_F_PREFIX) != 0;
+	else prefix = 0;
 	return rt6_fill_node(arg->skb, rt, NULL, NULL, 0, RTM_NEWROUTE,
 		     NETLINK_CB(arg->cb->skb).pid, arg->cb->nlh->nlmsg_seq,
-		     NULL);
+		     NULL, prefix);
 }

 static int fib6_dump_node(struct fib6_walker_t *w)
@@ -1757,7 +1770,7 @@
 			    fl.nl_u.ip6_u.saddr,
 			    iif,
 			    RTM_NEWROUTE, NETLINK_CB(in_skb).pid,
-			    nlh->nlmsg_seq, nlh);
+			    nlh->nlmsg_seq, nlh, 0);
 	if (err < 0) {
 		err = -EMSGSIZE;
 		goto out_free;
@@ -1783,7 +1796,7 @@
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_ROUTE, ENOBUFS);
 		return;
 	}
-	if (rt6_fill_node(skb, rt, NULL, NULL, 0, event, 0, 0, nlh) < 0) {
+	if (rt6_fill_node(skb, rt, NULL, NULL, 0, event, 0, 0, nlh, 0) < 0) {
 		kfree_skb(skb);
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_ROUTE, EINVAL);
 		return;


^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 2/2] Prefix List and O/M flags against 2.4.21
  2003-07-17 22:06                 ` [PATCH 2/2] Prefix List and O/M flags against 2.4.21 Krishna Kumar
@ 2003-07-17 22:22                   ` YOSHIFUJI Hideaki / 吉藤英明
  2003-07-17 22:34                     ` Krishna Kumar
  0 siblings, 1 reply; 52+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2003-07-17 22:22 UTC (permalink / raw)
  To: krkumar; +Cc: kuznet, davem, netdev, linux-net, yoshfuji

In article <Pine.LNX.4.44.0307171413100.1353-100000@DYN318430.beaverton.ibm.com> (at Thu, 17 Jul 2003 15:06:02 -0700 (PDT)), Krishna Kumar <krkumar@us.ibm.com> says:

> The same patch against 2.4.21

Hmm, you seems still misunderstanding some of our points. :-p
Alexey says we may want to use ifi_family for per-interface L3 information
including M/O bits. 
At least, new RTM_xxx should not be restricted to get such flags.

-- 
Hideaki YOSHIFUJI @ USAGI Project <yoshfuji@linux-ipv6.org>
GPG FP: 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 2/2] Prefix List and O/M flags against 2.4.21
  2003-07-17 22:22                   ` YOSHIFUJI Hideaki / 吉藤英明
@ 2003-07-17 22:34                     ` Krishna Kumar
  2003-07-17 22:47                       ` YOSHIFUJI Hideaki / 吉藤英明
  2003-07-21  1:55                       ` [PATCH 2/2] Prefix List and O/M flags against 2.4.21 kuznet
  0 siblings, 2 replies; 52+ messages in thread
From: Krishna Kumar @ 2003-07-17 22:34 UTC (permalink / raw)
  To: YOSHIFUJI Hideaki; +Cc: krkumar, kuznet, davem, netdev, linux-net

> Hmm, you seems still misunderstanding some of our points. :-p
> Alexey says we may want to use ifi_family for per-interface L3 information
> including M/O bits. 

It is not a misunderstanding, I had replied to that mail saying that I don't
have any knowledge of using this new interface. If you prefer, I can split the
patch for prefix list vs O/M bits so that the former is accepted without any
issues. Someone else can modify the O/M to suit new needs. Does that sound OK
with you ?

 > At least, new RTM_xxx should not be restricted to get such flags.

That's why I had suggested that we can use RTM_GETLNKINFO with more information,
like RTA_IFFLAGS, and other things like stats or whatever. That can be done
easily enough and still be functionally complete. I just don't have any idea
about this new interface.

Is this still a problem ?

thanks,

- KK

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 2/2] Prefix List and O/M flags against 2.4.21
  2003-07-17 22:34                     ` Krishna Kumar
@ 2003-07-17 22:47                       ` YOSHIFUJI Hideaki / 吉藤英明
  2003-07-18  0:37                         ` [PATCH 2/2] Prefix List and O/M flags against 2.5.73 Krishna Kumar
  2003-07-21  1:55                       ` [PATCH 2/2] Prefix List and O/M flags against 2.4.21 kuznet
  1 sibling, 1 reply; 52+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2003-07-17 22:47 UTC (permalink / raw)
  To: krkumar; +Cc: kuznet, davem, netdev, linux-net, yoshfuji

In article <3F17245D.9040806@us.ibm.com> (at Thu, 17 Jul 2003 15:34:05 -0700), Krishna Kumar <krkumar@us.ibm.com> says:

> have any knowledge of using this new interface. If you prefer, I can split the
> patch for prefix list vs O/M bits so that the former is accepted without any
> issues. Someone else can modify the O/M to suit new needs. Does that sound OK
> with you ?

Yes, please split up the patch.


>  > At least, new RTM_xxx should not be restricted to get such flags.
> 
> That's why I had suggested that we can use RTM_GETLNKINFO with more information,
> like RTA_IFFLAGS, and other things like stats or whatever. That can be done
> easily enough and still be functionally complete. I just don't have any idea
> about this new interface.
> 
> Is this still a problem ?

Hmm, I might miss something.
Anyway, it seems we're reaching consensus.

--yoshfuji

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 2/2] Prefix List and O/M flags against 2.5.73
  2003-07-17 22:47                       ` YOSHIFUJI Hideaki / 吉藤英明
@ 2003-07-18  0:37                         ` Krishna Kumar
  2003-07-19  6:47                           ` David S. Miller
                                             ` (2 more replies)
  0 siblings, 3 replies; 52+ messages in thread
From: Krishna Kumar @ 2003-07-18  0:37 UTC (permalink / raw)
  To: YOSHIFUJI Hideaki / 吉藤英明
  Cc: kuznet, davem, netdev, linux-net, krkumar

> Yes, please split up the patch.

Following is the split patch for prefix list and O/M flags.

> Anyway, it seems we're reaching consensus.

Great! Glad we have reached consensus because I am exhausted! Since you
have agreed to the above proposal, the prefix list patch has to be applied
before the O/M flags patch. I have kept the RTM_GETLNKINFO and specified
a new option to get the flags information, this can be extended later to
add more options for other paramters.

Thanks,

- KK

------------------- Patch for prefix list against 2.5.73 ------------
diff -ruN linux-2.5.73.org/include/linux/ipv6_route.h test/linux-2.5.73/include/linux/ipv6_route.h
--- linux-2.5.73.org/include/linux/ipv6_route.h	2003-06-22 11:32:36.000000000 -0700
+++ test/linux-2.5.73/include/linux/ipv6_route.h	2003-07-17 11:38:23.000000000 -0700
@@ -16,6 +16,7 @@
 #define RTF_DEFAULT	0x00010000	/* default - learned via ND	*/
 #define RTF_ALLONLINK	0x00020000	/* fallback, no routers on link	*/
 #define RTF_ADDRCONF	0x00040000	/* addrconf route - RA		*/
+#define RTF_PREFIX_RT	0x00080000	/* A prefix only route - RA	*/

 #define RTF_NONEXTHOP	0x00200000	/* route with no nexthop	*/
 #define RTF_EXPIRES	0x00400000
diff -ruN linux-2.5.73.org/include/linux/rtnetlink.h test/linux-2.5.73/include/linux/rtnetlink.h
--- linux-2.5.73.org/include/linux/rtnetlink.h	2003-06-22 11:33:07.000000000 -0700
+++ test/linux-2.5.73/include/linux/rtnetlink.h	2003-07-17 16:57:52.000000000 -0700
@@ -168,6 +168,7 @@
 #define RTM_F_NOTIFY		0x100	/* Notify user of route change	*/
 #define RTM_F_CLONED		0x200	/* This route is cloned		*/
 #define RTM_F_EQUALIZE		0x400	/* Multipath equalizer: NI	*/
+#define RTM_F_PREFIX		0x800	/* Prefix addresses		*/

 /* Reserved table identifiers */

diff -ruN linux-2.5.73.org/net/ipv6/addrconf.c test/linux-2.5.73/net/ipv6/addrconf.c
--- linux-2.5.73.org/net/ipv6/addrconf.c	2003-06-22 11:33:17.000000000 -0700
+++ test/linux-2.5.73/net/ipv6/addrconf.c	2003-07-17 16:59:17.000000000 -0700
@@ -129,7 +129,7 @@

 static int addrconf_ifdown(struct net_device *dev, int how);

-static void addrconf_dad_start(struct inet6_ifaddr *ifp);
+static void addrconf_dad_start(struct inet6_ifaddr *ifp, int flags);
 static void addrconf_dad_timer(unsigned long data);
 static void addrconf_dad_completed(struct inet6_ifaddr *ifp);
 static void addrconf_rs_timer(unsigned long data);
@@ -715,7 +715,7 @@
 	ift->prefered_lft = tmp_prefered_lft;
 	ift->tstamp = ifp->tstamp;
 	spin_unlock_bh(&ift->lock);
-	addrconf_dad_start(ift);
+	addrconf_dad_start(ift, 0);
 	in6_ifa_put(ift);
 	in6_dev_put(idev);
 out:
@@ -1211,7 +1211,7 @@
 	rtmsg.rtmsg_dst_len = 8;
 	rtmsg.rtmsg_metric = IP6_RT_PRIO_ADDRCONF;
 	rtmsg.rtmsg_ifindex = dev->ifindex;
-	rtmsg.rtmsg_flags = RTF_UP|RTF_ADDRCONF;
+	rtmsg.rtmsg_flags = RTF_UP;
 	rtmsg.rtmsg_type = RTMSG_NEWROUTE;
 	ip6_route_add(&rtmsg, NULL, NULL);
 }
@@ -1238,7 +1238,7 @@
 	struct in6_addr addr;

 	ipv6_addr_set(&addr,  htonl(0xFE800000), 0, 0, 0);
-	addrconf_prefix_route(&addr, 64, dev, 0, RTF_ADDRCONF);
+	addrconf_prefix_route(&addr, 64, dev, 0, 0);
 }

 static struct inet6_dev *addrconf_add_dev(struct net_device *dev)
@@ -1330,7 +1330,8 @@
 		}
 	} else if (pinfo->onlink && valid_lft) {
 		addrconf_prefix_route(&pinfo->prefix, pinfo->prefix_len,
-				      dev, rt_expires, RTF_ADDRCONF|RTF_EXPIRES);
+				      dev, rt_expires,
+				      RTF_ADDRCONF|RTF_EXPIRES|RTF_PREFIX_RT);
 	}
 	if (rt)
 		dst_release(&rt->u.dst);
@@ -1378,7 +1379,7 @@
 			}

 			create = 1;
-			addrconf_dad_start(ifp);
+			addrconf_dad_start(ifp, RTF_ADDRCONF|RTF_PREFIX_RT);
 		}

 		if (ifp && valid_lft == 0) {
@@ -1529,7 +1530,7 @@

 	ifp = ipv6_add_addr(idev, pfx, plen, scope, IFA_F_PERMANENT);
 	if (!IS_ERR(ifp)) {
-		addrconf_dad_start(ifp);
+		addrconf_dad_start(ifp, 0);
 		in6_ifa_put(ifp);
 		return 0;
 	}
@@ -1704,7 +1705,7 @@

 	ifp = ipv6_add_addr(idev, addr, 64, IFA_LINK, IFA_F_PERMANENT);
 	if (!IS_ERR(ifp)) {
-		addrconf_dad_start(ifp);
+		addrconf_dad_start(ifp, 0);
 		in6_ifa_put(ifp);
 	}
 }
@@ -1943,8 +1944,7 @@
 		memset(&rtmsg, 0, sizeof(struct in6_rtmsg));
 		rtmsg.rtmsg_type = RTMSG_NEWROUTE;
 		rtmsg.rtmsg_metric = IP6_RT_PRIO_ADDRCONF;
-		rtmsg.rtmsg_flags = (RTF_ALLONLINK | RTF_ADDRCONF |
-				     RTF_DEFAULT | RTF_UP);
+		rtmsg.rtmsg_flags = (RTF_ALLONLINK | RTF_DEFAULT | RTF_UP);

 		rtmsg.rtmsg_ifindex = ifp->idev->dev->ifindex;

@@ -1958,7 +1958,7 @@
 /*
  *	Duplicate Address Detection
  */
-static void addrconf_dad_start(struct inet6_ifaddr *ifp)
+static void addrconf_dad_start(struct inet6_ifaddr *ifp, int flags)
 {
 	struct net_device *dev;
 	unsigned long rand_num;
@@ -1968,7 +1968,7 @@
 	addrconf_join_solict(dev, &ifp->addr);

 	if (ifp->prefix_len != 128 && (ifp->flags&IFA_F_PERMANENT))
-		addrconf_prefix_route(&ifp->addr, ifp->prefix_len, dev, 0, RTF_ADDRCONF);
+		addrconf_prefix_route(&ifp->addr, ifp->prefix_len, dev, 0, flags);

 	net_srandom(ifp->addr.s6_addr32[3]);
 	rand_num = net_random() % (ifp->idev->cnf.rtr_solicit_delay ? : 1);
diff -ruN linux-2.5.73.org/net/ipv6/route.c test/linux-2.5.73/net/ipv6/route.c
--- linux-2.5.73.org/net/ipv6/route.c	2003-06-22 11:33:05.000000000 -0700
+++ test/linux-2.5.73/net/ipv6/route.c	2003-07-16 10:42:01.000000000 -0700
@@ -1400,13 +1400,20 @@
 			 struct in6_addr *src,
 			 int iif,
 			 int type, u32 pid, u32 seq,
-			 struct nlmsghdr *in_nlh)
+			 struct nlmsghdr *in_nlh, int prefix)
 {
 	struct rtmsg *rtm;
 	struct nlmsghdr  *nlh;
 	unsigned char	 *b = skb->tail;
 	struct rta_cacheinfo ci;

+	if (prefix) {	/* user wants prefix routes only */
+		if (!(rt->rt6i_flags & RTF_PREFIX_RT)) {
+			/* success since this is not a prefix route */
+			return 1;
+		}
+	}
+
 	if (!pid && in_nlh) {
 		pid = in_nlh->nlmsg_pid;
 	}
@@ -1487,10 +1494,16 @@
 static int rt6_dump_route(struct rt6_info *rt, void *p_arg)
 {
 	struct rt6_rtnl_dump_arg *arg = (struct rt6_rtnl_dump_arg *) p_arg;
+	struct rtmsg *rtm;
+	int prefix;

+	rtm = NLMSG_DATA(arg->cb->nlh);
+	if (rtm)
+		prefix = (rtm->rtm_flags & RTM_F_PREFIX) != 0;
+	else prefix = 0;
 	return rt6_fill_node(arg->skb, rt, NULL, NULL, 0, RTM_NEWROUTE,
 		     NETLINK_CB(arg->cb->skb).pid, arg->cb->nlh->nlmsg_seq,
-		     NULL);
+		     NULL, prefix);
 }

 static int fib6_dump_node(struct fib6_walker_t *w)
@@ -1638,7 +1651,7 @@
 			    &fl.fl6_dst, &fl.fl6_src,
 			    iif,
 			    RTM_NEWROUTE, NETLINK_CB(in_skb).pid,
-			    nlh->nlmsg_seq, nlh);
+			    nlh->nlmsg_seq, nlh, 0);
 	if (err < 0) {
 		err = -EMSGSIZE;
 		goto out_free;
@@ -1664,7 +1677,7 @@
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_ROUTE, ENOBUFS);
 		return;
 	}
-	if (rt6_fill_node(skb, rt, NULL, NULL, 0, event, 0, 0, nlh) < 0) {
+	if (rt6_fill_node(skb, rt, NULL, NULL, 0, event, 0, 0, nlh, 0) < 0) {
 		kfree_skb(skb);
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_ROUTE, EINVAL);
 		return;
-------- Patch for O/M flags against 2.5.73 (dependent on previous patch -----
diff -ruN linux-2.5.73.org/include/linux/rtnetlink.h test/linux-2.5.73/include/linux/rtnetlink.h
--- linux-2.5.73.org/include/linux/rtnetlink.h	2003-06-22 11:33:07.000000000 -0700
+++ test/linux-2.5.73/include/linux/rtnetlink.h	2003-07-17 16:57:52.000000000 -0700
@@ -47,7 +47,9 @@
 #define	RTM_DELTFILTER	(RTM_BASE+29)
 #define	RTM_GETTFILTER	(RTM_BASE+30)

-#define	RTM_MAX		(RTM_BASE+31)
+#define	RTM_GETLNKINFO	(RTM_BASE+34)
+
+#define	RTM_MAX		(RTM_GETLNKINFO+1)

 /*
    Generic structure for encapsulation of optional route information.
@@ -61,6 +63,13 @@
 	unsigned short	rta_type;
 };

+/* Structure to return per interface device flags */
+struct ifp_if6info
+{
+	int ifindex;
+	int flags;
+};
+
 /* Macros to handle rtattributes */

 #define RTA_ALIGNTO	4
@@ -331,6 +340,7 @@
 	IFA_LABEL,
 	IFA_BROADCAST,
 	IFA_ANYCAST,
+	IFA_IFFLAGS,
 	IFA_CACHEINFO
 };

diff -ruN linux-2.5.73.org/include/net/if_inet6.h test/linux-2.5.73/include/net/if_inet6.h
--- linux-2.5.73.org/include/net/if_inet6.h	2003-06-22 11:33:32.000000000 -0700
+++ test/linux-2.5.73/include/net/if_inet6.h	2003-07-16 17:23:24.000000000 -0700
@@ -17,6 +17,8 @@

 #include <net/snmp.h>

+#define IF_RA_OTHERCONF	0x80
+#define IF_RA_MANAGED	0x40
 #define IF_RA_RCVD	0x20
 #define IF_RS_SENT	0x10

diff -ruN linux-2.5.73.org/net/ipv6/addrconf.c test/linux-2.5.73/net/ipv6/addrconf.c
--- linux-2.5.73.org/net/ipv6/addrconf.c	2003-06-22 11:33:17.000000000 -0700
+++ test/linux-2.5.73/net/ipv6/addrconf.c	2003-07-17 16:59:17.000000000 -0700
@@ -2451,6 +2451,43 @@
 	netlink_broadcast(rtnl, skb, 0, RTMGRP_IPV6_IFADDR, GFP_ATOMIC);
 }

+int inet6_dump_linkinfo(struct sk_buff *skb, struct netlink_callback *cb)
+{
+	int ifindex, flags;
+	struct net_device *dev;
+	struct inet6_dev *idev;
+	struct nlmsghdr *nlh;
+	struct ifp_if6info ifp, *input_ifp = NLMSG_DATA(cb->nlh);
+	unsigned char *org_tail = skb->tail;
+
+	ifindex = input_ifp->ifindex;
+	if ((dev = dev_get_by_index(ifindex)) == NULL)
+		goto out;
+	if ((idev = in6_dev_get(dev)) != NULL) {
+		flags = idev->if_flags;
+		in6_dev_put(idev);
+	} else
+		flags = 0;
+	dev_put(dev);
+
+	nlh = NLMSG_PUT(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq,
+			RTM_GETLNKINFO, sizeof(*input_ifp));
+	ifp.flags = flags;
+	ifp.ifindex = ifindex;    /* duplicate info for user to verify */
+	RTA_PUT(skb, IFA_IFFLAGS, sizeof(ifp), &ifp);
+
+	nlh->nlmsg_len = skb->tail - org_tail;
+	return skb->len;
+
+nlmsg_failure:
+rtattr_failure:
+	printk(KERN_INFO "inet6_dump_linkinfo:skb size not enough\n");
+	skb_trim(skb, org_tail - skb->data);
+
+out:
+	return -1;
+}
+
 static struct rtnetlink_link inet6_rtnetlink_table[RTM_MAX - RTM_BASE + 1] = {
 	[RTM_NEWADDR - RTM_BASE] = { .doit	= inet6_rtm_newaddr, },
 	[RTM_DELADDR - RTM_BASE] = { .doit	= inet6_rtm_deladdr, },
@@ -2459,6 +2496,7 @@
 	[RTM_DELROUTE - RTM_BASE] = { .doit	= inet6_rtm_delroute, },
 	[RTM_GETROUTE - RTM_BASE] = { .doit	= inet6_rtm_getroute,
 				      .dumpit	= inet6_dump_fib, },
+	[RTM_GETLNKINFO - RTM_BASE] = {.dumpit	= inet6_dump_linkinfo, },
 };

 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
diff -ruN linux-2.5.73.org/net/ipv6/ndisc.c test/linux-2.5.73/net/ipv6/ndisc.c
--- linux-2.5.73.org/net/ipv6/ndisc.c	2003-06-22 11:32:56.000000000 -0700
+++ test/linux-2.5.73/net/ipv6/ndisc.c	2003-07-14 15:06:14.000000000 -0700
@@ -1036,6 +1036,16 @@
 		 */
 		in6_dev->if_flags |= IF_RA_RCVD;
 	}
+	/*
+	 * Remember the managed/otherconf flags from most recently
+	 * receieved RA message (RFC 2462) -- yoshfuji
+	 */
+	in6_dev->if_flags = (in6_dev->if_flags & ~(IF_RA_MANAGED|
+				IF_RA_OTHERCONF)) |
+				(ra_msg->icmph.icmp6_addrconf_managed ?
+					IF_RA_MANAGED : 0) |
+				(ra_msg->icmph.icmp6_addrconf_other ?
+					IF_RA_OTHERCONF : 0);

 	lifetime = ntohs(ra_msg->icmph.icmp6_rt_lifetime);

------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 2/2] Prefix List and O/M flags against 2.5.73
  2003-07-18  0:37                         ` [PATCH 2/2] Prefix List and O/M flags against 2.5.73 Krishna Kumar
@ 2003-07-19  6:47                           ` David S. Miller
  2003-07-19  7:33                           ` YOSHIFUJI Hideaki / 吉藤英明
  2003-07-21 12:17                           ` David S. Miller
  2 siblings, 0 replies; 52+ messages in thread
From: David S. Miller @ 2003-07-19  6:47 UTC (permalink / raw)
  To: Krishna Kumar; +Cc: yoshfuji, kuznet, netdev, linux-net, krkumar

On Thu, 17 Jul 2003 17:37:18 -0700 (PDT)
Krishna Kumar <krkumar@us.ibm.com> wrote:

> > Yes, please split up the patch.
> 
> Following is the split patch for prefix list and O/M flags.

Alexey, others, please tell me if I should apply these
two patches.

Thanks.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 2/2] Prefix List and O/M flags against 2.5.73
  2003-07-18  0:37                         ` [PATCH 2/2] Prefix List and O/M flags against 2.5.73 Krishna Kumar
  2003-07-19  6:47                           ` David S. Miller
@ 2003-07-19  7:33                           ` YOSHIFUJI Hideaki / 吉藤英明
  2003-07-21  0:49                             ` kuznet
  2003-07-21 12:17                           ` David S. Miller
  2 siblings, 1 reply; 52+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2003-07-19  7:33 UTC (permalink / raw)
  To: krkumar; +Cc: kuznet, davem, netdev, linux-net

In article <Pine.LNX.4.44.0307171716160.9419-100000@DYN318430.beaverton.ibm.com> (at Thu, 17 Jul 2003 17:37:18 -0700 (PDT)), Krishna Kumar <krkumar@us.ibm.com> says:

> > Anyway, it seems we're reaching consensus.
> 
> Great! Glad we have reached consensus because I am exhausted! Since you
> have agreed to the above proposal, the prefix list patch has to be applied
> before the O/M flags patch. I have kept the RTM_GETLNKINFO and specified
> a new option to get the flags information, this can be extended later to
> add more options for other paramters.

We're reaching consensus, but hot have reached. :-p
First part (prefixlist) seems ok to me.
Second part does not.

> -------- Patch for O/M flags against 2.5.73 (dependent on previous patch -----
> diff -ruN linux-2.5.73.org/include/linux/rtnetlink.h test/linux-2.5.73/include/linux/rtnetlink.h
> --- linux-2.5.73.org/include/linux/rtnetlink.h	2003-06-22 11:33:07.000000000 -0700
> +++ test/linux-2.5.73/include/linux/rtnetlink.h	2003-07-17 16:57:52.000000000 -0700
> @@ -47,7 +47,9 @@
>  #define	RTM_DELTFILTER	(RTM_BASE+29)
>  #define	RTM_GETTFILTER	(RTM_BASE+30)
> 
> -#define	RTM_MAX		(RTM_BASE+31)
> +#define	RTM_GETLNKINFO	(RTM_BASE+34)
> +
> +#define	RTM_MAX		(RTM_GETLNKINFO+1)
> 
>  /*
>     Generic structure for encapsulation of optional route information.

This is what we don't have consensus.
We need to decide whether to create new RTM_xxxIFACE or
to reuse RTM_xxxLINK (and activate ifi_family :-)).


> @@ -61,6 +63,13 @@
>  	unsigned short	rta_type;
>  };
> 
> +/* Structure to return per interface device flags */
> +struct ifp_if6info
> +{
> +	int ifindex;
> +	int flags;
> +};
> +
>  /* Macros to handle rtattributes */
> 
>  #define RTA_ALIGNTO	4

ditto.

> @@ -331,6 +340,7 @@
>  	IFA_LABEL,
>  	IFA_BROADCAST,
>  	IFA_ANYCAST,
> +	IFA_IFFLAGS,
>  	IFA_CACHEINFO
>  };

Don't change values.

> diff -ruN linux-2.5.73.org/net/ipv6/addrconf.c test/linux-2.5.73/net/ipv6/addrconf.c
> --- linux-2.5.73.org/net/ipv6/addrconf.c	2003-06-22 11:33:17.000000000 -0700
> +++ test/linux-2.5.73/net/ipv6/addrconf.c	2003-07-17 16:59:17.000000000 -0700
> @@ -2451,6 +2451,43 @@
>  	netlink_broadcast(rtnl, skb, 0, RTMGRP_IPV6_IFADDR, GFP_ATOMIC);
>  }
> 
> +int inet6_dump_linkinfo(struct sk_buff *skb, struct netlink_callback *cb)
> +{
> +	int ifindex, flags;
> +	struct net_device *dev;
:
>  static struct rtnetlink_link inet6_rtnetlink_table[RTM_MAX - RTM_BASE + 1] = {
>  	[RTM_NEWADDR - RTM_BASE] = { .doit	= inet6_rtm_newaddr, },
>  	[RTM_DELADDR - RTM_BASE] = { .doit	= inet6_rtm_deladdr, },
> @@ -2459,6 +2496,7 @@
>  	[RTM_DELROUTE - RTM_BASE] = { .doit	= inet6_rtm_delroute, },
>  	[RTM_GETROUTE - RTM_BASE] = { .doit	= inet6_rtm_getroute,
>  				      .dumpit	= inet6_dump_fib, },
> +	[RTM_GETLNKINFO - RTM_BASE] = {.dumpit	= inet6_dump_linkinfo, },
>  };
> 

same as first comment for this part.

-- 
Hideaki YOSHIFUJI @ USAGI Project <yoshfuji@linux-ipv6.org>
GPG FP: 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 2/2] Prefix List and O/M flags against 2.5.73
  2003-07-19  7:33                           ` YOSHIFUJI Hideaki / 吉藤英明
@ 2003-07-21  0:49                             ` kuznet
  0 siblings, 0 replies; 52+ messages in thread
From: kuznet @ 2003-07-21  0:49 UTC (permalink / raw)
  To: YOSHIFUJIHideaki/吉藤英明
  Cc: krkumar, davem, netdev, linux-net

Hello!

> First part (prefixlist) seems ok to me.

The same is here. It looks good.


> Second part does not.

I do not like the latest version a lot. :-) Actually, previous one was
quite acceptable, but I think Yoshfuji's suggestion is so good that
it makes lots of sense to complete it. I could make this in IPv4 part,
actually, I started to make it as demo for Krishna, but two questions
remained unaswered:

1. How to allocate new attributes? It is bad just to add them to existing
IFLA_* ones or override them. I would suggest to create new attribute
IFLA_PROTINFO and to embed new protocol dependant attributes as 
subattributes a la RTA_METRICS. Another suggestions?

2. IFLA_INET6_CONF (and IFLA_INET_CONF). How to encode the values?
Array of int's is simple, compact and looks good. But I have some problem
with it. What if one day we want to implement changing the values?
It will be nasty. To forget about such perspective? Or to leave it to use
for "atomic" load of all the parameters?

Alexey

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 2/2] Prefix List and O/M flags against 2.4.21
  2003-07-17 22:34                     ` Krishna Kumar
  2003-07-17 22:47                       ` YOSHIFUJI Hideaki / 吉藤英明
@ 2003-07-21  1:55                       ` kuznet
  2003-07-21  4:46                         ` David S. Miller
                                           ` (2 more replies)
  1 sibling, 3 replies; 52+ messages in thread
From: kuznet @ 2003-07-21  1:55 UTC (permalink / raw)
  To: Krishna Kumar; +Cc: yoshfuji, krkumar, davem, netdev, linux-net

Hello!

>								I don't
> have any knowledge of using this new interface.

Something like this.

See? I just substitute into xxx_rtnetlink_table() entry for RTM_GETLINK
with IPv4 specific function which outputs the same message, but, maybe,
with some attributes removed and with new protocol-specific attribute.

The patch is not quite complete: except for those two questions,
I forgot to add MTU truncated to its IPv4 value, did nothing
for multicast things (I still cannot figure out, what information is
really useful) and did not add active notifications which would be good
to be made after sysctl parameters are changed.

Alexey


# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	1.1469  -> 1.1470 
#	  net/ipv4/devinet.c	1.19    -> 1.20   
#	include/linux/rtnetlink.h	1.18    -> 1.19   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/07/21	kuznet@oops.inr.ac.ru	1.1470
# Reporting INET config via rtnetlink
# --------------------------------------------
#
diff -Nru a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
--- a/include/linux/rtnetlink.h	Mon Jul 21 05:47:01 2003
+++ b/include/linux/rtnetlink.h	Mon Jul 21 05:47:01 2003
@@ -476,10 +476,12 @@
 #define IFLA_MASTER IFLA_MASTER
 	IFLA_WIRELESS,		/* Wireless Extension event - see wireless.h */
 #define IFLA_WIRELESS IFLA_WIRELESS
+	IFLA_PROTINFO,
+#define IFLA_PROTINFO IFLA_PROTINFO
 };
 
 
-#define IFLA_MAX IFLA_WIRELESS
+#define IFLA_MAX IFLA_PROTINFO
 
 #define IFLA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
 #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
@@ -512,6 +514,16 @@
    or maybe 0, what means, that real media is unknown (usual
    for IPIP tunnels, when route to endpoint is allowed to change)
  */
+
+enum
+{
+	IFLA_INET_UNSPEC,
+	IFLA_INET_CONF,		/* sysctl parameters	*/
+	IFLA_INET_NEIGH,	/* ARP parameters	*/
+	IFLA_INET_MCAST,	/* MC things. What of them? */
+};
+
+#define IFLA_INET_MAX IFLA_INET_CONF
 
 /*****************************************************************
  *		Traffic control messages.
diff -Nru a/net/ipv4/devinet.c b/net/ipv4/devinet.c
--- a/net/ipv4/devinet.c	Mon Jul 21 05:47:01 2003
+++ b/net/ipv4/devinet.c	Mon Jul 21 05:47:01 2003
@@ -1008,17 +1008,88 @@
 	}
 }
 
+static int inet_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
+			    struct in_device *in_dev,
+			    int type, u32 pid, u32 seq)
+{
+	struct ifinfomsg *r;
+	struct nlmsghdr  *nlh;
+	unsigned char	 *b = skb->tail;
+	struct rtattr	 *subattr;
+
+	nlh = NLMSG_PUT(skb, pid, seq, type, sizeof(*r));
+	if (pid) nlh->nlmsg_flags |= NLM_F_MULTI;
+	r = NLMSG_DATA(nlh);
+	r->ifi_family = AF_INET;
+	r->ifi_type = dev->type;
+	r->ifi_index = dev->ifindex;
+	r->ifi_flags = dev->flags;
+	r->ifi_change = 0;
+
+	if (!netif_running(dev) || !netif_carrier_ok(dev))
+		r->ifi_flags &= ~IFF_RUNNING;
+	else
+		r->ifi_flags |= IFF_RUNNING;
+
+	RTA_PUT(skb, IFLA_IFNAME, strlen(dev->name)+1, dev->name);
+
+	/* Some more IFLA_* attribute fr convenience? IPv4-ized MTU
+	 * would be good idea.
+	 */
+
+	subattr = (struct rtattr*)skb->tail;
+	RTA_PUT(skb, IFLA_PROTINFO, 0, NULL);
+	RTA_PUT(skb, IFLA_INET_CONF, sizeof(int)*16, &in_dev->cnf);
+	RTA_PUT(skb, IFLA_INET_NEIGH, sizeof(int)*13, &in_dev->arp_parms->base_reachable_time);
+	subattr->rta_len = skb->tail - (u8*)subattr;
+
+	nlh->nlmsg_len = skb->tail - b;
+	return skb->len;
+
+nlmsg_failure:
+rtattr_failure:
+	skb_trim(skb, b - skb->data);
+	return -1;
+}
+
+
+int inet_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
+{
+	int idx, err;
+	int s_idx = cb->args[0];
+	struct net_device *dev;
+	struct in_device *in_dev;
+
+	read_lock(&dev_base_lock);
+	for (dev=dev_base, idx=0; dev; dev = dev->next, idx++) {
+		if (idx < s_idx)
+			continue;
+		if ((in_dev = in_dev_get(dev)) == NULL)
+			continue;
+		err = inet_fill_ifinfo(skb, dev, in_dev, RTM_NEWLINK, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq);
+		in_dev_put(in_dev);
+		if (err <= 0)
+			break;
+	}
+	read_unlock(&dev_base_lock);
+	cb->args[0] = idx;
+
+	return skb->len;
+}
+
+
 static struct rtnetlink_link inet_rtnetlink_table[RTM_MAX - RTM_BASE + 1] = {
-	 [4] = { .doit	 = inet_rtm_newaddr,  },
-	 [5] = { .doit	 = inet_rtm_deladdr,  },
-	 [6] = { .dumpit = inet_dump_ifaddr,  },
-	 [8] = { .doit	 = inet_rtm_newroute, },
-	 [9] = { .doit	 = inet_rtm_delroute, },
-	[10] = { .doit	 = inet_rtm_getroute, .dumpit = inet_dump_fib, },
+	[RTM_GETLINK  - RTM_BASE] = { .dumpit	= inet_dump_ifinfo,  },
+	[RTM_NEWADDR  - RTM_BASE] = { .doit	= inet_rtm_newaddr,  },
+	[RTM_DELADDR  - RTM_BASE] = { .doit	= inet_rtm_deladdr,  },
+	[RTM_GETADDR  - RTM_BASE] = { .dumpit	= inet_dump_ifaddr,  },
+	[RTM_NEWROUTE  - RTM_BASE] = { .doit	= inet_rtm_newroute, },
+	[RTM_DELROUTE  - RTM_BASE] = { .doit	= inet_rtm_delroute, },
+	[RTM_GETROUTE  - RTM_BASE] = { .doit	= inet_rtm_getroute, .dumpit = inet_dump_fib, },
 #ifdef CONFIG_IP_MULTIPLE_TABLES
-	[16] = { .doit	 = inet_rtm_newrule, },
-	[17] = { .doit	 = inet_rtm_delrule, },
-	[18] = { .dumpit = inet_dump_rules,  },
+	[RTM_NEWRULE  - RTM_BASE] = { .doit	= inet_rtm_newrule, },
+	[RTM_DELRULE  - RTM_BASE] = { .doit	= inet_rtm_delrule, },
+	[RTM_GETRULE  - RTM_BASE] = { .dumpit	= inet_dump_rules,  },
 #endif
 };
 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 2/2] Prefix List and O/M flags against 2.4.21
  2003-07-21  1:55                       ` [PATCH 2/2] Prefix List and O/M flags against 2.4.21 kuznet
@ 2003-07-21  4:46                         ` David S. Miller
  2003-07-22 21:50                         ` O/M flags against 2.6.0-test1 Krishna Kumar
  2003-07-22 23:52                         ` [PATCH] Prefix List against 2.4.21 Krishna Kumar
  2 siblings, 0 replies; 52+ messages in thread
From: David S. Miller @ 2003-07-21  4:46 UTC (permalink / raw)
  To: kuznet; +Cc: krkumar, yoshfuji, netdev, linux-net

On Mon, 21 Jul 2003 05:55:04 +0400 (MSD)
kuznet@ms2.inr.ac.ru wrote:

> The patch is not quite complete: except for those two questions,
> I forgot to add MTU truncated to its IPv4 value, did nothing
> for multicast things (I still cannot figure out, what information is
> really useful) and did not add active notifications which would be good
> to be made after sysctl parameters are changed.

Please let us to use some portable types instead of
'int' :-)  It is just minor nit, I otherwise like the
whole idea.

Why are we limited to arrays of 'u32' or whatever?  RTA_PUT() can
place arbitrary things into the message and length is given.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 2/2] Prefix List and O/M flags against 2.5.73
  2003-07-18  0:37                         ` [PATCH 2/2] Prefix List and O/M flags against 2.5.73 Krishna Kumar
  2003-07-19  6:47                           ` David S. Miller
  2003-07-19  7:33                           ` YOSHIFUJI Hideaki / 吉藤英明
@ 2003-07-21 12:17                           ` David S. Miller
  2003-07-21 17:16                             ` Krishna Kumar
  2 siblings, 1 reply; 52+ messages in thread
From: David S. Miller @ 2003-07-21 12:17 UTC (permalink / raw)
  To: Krishna Kumar; +Cc: yoshfuji, kuznet, netdev, linux-net, krkumar

On Thu, 17 Jul 2003 17:37:18 -0700 (PDT)
Krishna Kumar <krkumar@us.ibm.com> wrote:

> ------------------- Patch for prefix list against 2.5.73 ------------

Ok, I tried to apply this, but it had lots of rejects, here
is why.

> diff -ruN linux-2.5.73.org/net/ipv6/addrconf.c test/linux-2.5.73/net/ipv6/addrconf.c
> --- linux-2.5.73.org/net/ipv6/addrconf.c	2003-06-22 11:33:17.000000000 -0700
> +++ test/linux-2.5.73/net/ipv6/addrconf.c	2003-07-17 16:59:17.000000000 -0700
 ...
> @@ -1330,7 +1330,8 @@
>  		}
>  	} else if (pinfo->onlink && valid_lft) {
>  		addrconf_prefix_route(&pinfo->prefix, pinfo->prefix_len,

The "pinfo->onlink" part of this if test does not exist
in the sources, so patch application failed.

You're mixing this patch up with other changes in your
tree already.

Please repatch against current 2.6.x sources.
Thanks.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 2/2] Prefix List and O/M flags against 2.5.73
  2003-07-21 12:17                           ` David S. Miller
@ 2003-07-21 17:16                             ` Krishna Kumar
  0 siblings, 0 replies; 52+ messages in thread
From: Krishna Kumar @ 2003-07-21 17:16 UTC (permalink / raw)
  To: David S. Miller; +Cc: yoshfuji, kuznet, netdev, linux-net, krkumar



> Ok, I tried to apply this, but it had lots of rejects, here
> is why.
>
> > diff -ruN linux-2.5.73.org/net/ipv6/addrconf.c test/linux-2.5.73/net/ipv6/addrconf.c
> > --- linux-2.5.73.org/net/ipv6/addrconf.c	2003-06-22 11:33:17.000000000 -0700
> > +++ test/linux-2.5.73/net/ipv6/addrconf.c	2003-07-17 16:59:17.000000000 -0700
>  ...
> > @@ -1330,7 +1330,8 @@
> >  		}
> >  	} else if (pinfo->onlink && valid_lft) {
> >  		addrconf_prefix_route(&pinfo->prefix, pinfo->prefix_len,
>
> The "pinfo->onlink" part of this if test does not exist
> in the sources, so patch application failed.
>
> You're mixing this patch up with other changes in your
> tree already.

The problem happened since the patch was against 2.5.73, and this line
seems to have been changed sometime after that before 2.6.0. Following
is the prefix list (only) patch against 2.6.0-test1 bits.

Thanks,

- KK

-------------------------------------------------------------------------------

diff -ruN linux-2.6.0-test1.org/include/linux/ipv6_route.h linux-2.6.0-test1.new/include/linux/ipv6_route.h
--- linux-2.6.0-test1.org/include/linux/ipv6_route.h	2003-07-13 20:31:50.000000000 -0700
+++ linux-2.6.0-test1.new/include/linux/ipv6_route.h	2003-07-21 09:50:54.000000000 -0700
@@ -16,6 +16,7 @@
 #define RTF_DEFAULT	0x00010000	/* default - learned via ND	*/
 #define RTF_ALLONLINK	0x00020000	/* fallback, no routers on link	*/
 #define RTF_ADDRCONF	0x00040000	/* addrconf route - RA		*/
+#define RTF_PREFIX_RT	0x00080000	/* A prefix only route - RA	*/

 #define RTF_NONEXTHOP	0x00200000	/* route with no nexthop	*/
 #define RTF_EXPIRES	0x00400000
diff -ruN linux-2.6.0-test1.org/include/linux/rtnetlink.h linux-2.6.0-test1.new/include/linux/rtnetlink.h
--- linux-2.6.0-test1.org/include/linux/rtnetlink.h	2003-07-13 20:37:13.000000000 -0700
+++ linux-2.6.0-test1.new/include/linux/rtnetlink.h	2003-07-21 09:51:29.000000000 -0700
@@ -168,6 +168,7 @@
 #define RTM_F_NOTIFY		0x100	/* Notify user of route change	*/
 #define RTM_F_CLONED		0x200	/* This route is cloned		*/
 #define RTM_F_EQUALIZE		0x400	/* Multipath equalizer: NI	*/
+#define RTM_F_PREFIX		0x800	/* Prefix addresses		*/

 /* Reserved table identifiers */

diff -ruN linux-2.6.0-test1.org/net/ipv6/addrconf.c linux-2.6.0-test1.new/net/ipv6/addrconf.c
--- linux-2.6.0-test1.org/net/ipv6/addrconf.c	2003-07-13 20:38:06.000000000 -0700
+++ linux-2.6.0-test1.new/net/ipv6/addrconf.c	2003-07-21 09:56:19.000000000 -0700
@@ -130,7 +130,7 @@

 static int addrconf_ifdown(struct net_device *dev, int how);

-static void addrconf_dad_start(struct inet6_ifaddr *ifp);
+static void addrconf_dad_start(struct inet6_ifaddr *ifp, int flags);
 static void addrconf_dad_timer(unsigned long data);
 static void addrconf_dad_completed(struct inet6_ifaddr *ifp);
 static void addrconf_rs_timer(unsigned long data);
@@ -716,7 +716,7 @@
 	ift->prefered_lft = tmp_prefered_lft;
 	ift->tstamp = ifp->tstamp;
 	spin_unlock_bh(&ift->lock);
-	addrconf_dad_start(ift);
+	addrconf_dad_start(ift, 0);
 	in6_ifa_put(ift);
 	in6_dev_put(idev);
 out:
@@ -1249,7 +1249,7 @@
 	rtmsg.rtmsg_dst_len = 8;
 	rtmsg.rtmsg_metric = IP6_RT_PRIO_ADDRCONF;
 	rtmsg.rtmsg_ifindex = dev->ifindex;
-	rtmsg.rtmsg_flags = RTF_UP|RTF_ADDRCONF;
+	rtmsg.rtmsg_flags = RTF_UP;
 	rtmsg.rtmsg_type = RTMSG_NEWROUTE;
 	ip6_route_add(&rtmsg, NULL, NULL);
 }
@@ -1276,7 +1276,7 @@
 	struct in6_addr addr;

 	ipv6_addr_set(&addr,  htonl(0xFE800000), 0, 0, 0);
-	addrconf_prefix_route(&addr, 64, dev, 0, RTF_ADDRCONF);
+	addrconf_prefix_route(&addr, 64, dev, 0, 0);
 }

 static struct inet6_dev *addrconf_add_dev(struct net_device *dev)
@@ -1369,7 +1369,7 @@
 			}
 		} else if (valid_lft) {
 			addrconf_prefix_route(&pinfo->prefix, pinfo->prefix_len,
-					      dev, rt_expires, RTF_ADDRCONF|RTF_EXPIRES);
+					      dev, rt_expires, RTF_ADDRCONF|RTF_EXPIRES|RTF_PREFIX_RT);
 		}
 		if (rt)
 			dst_release(&rt->u.dst);
@@ -1415,7 +1415,7 @@
 			}

 			update_lft = create = 1;
-			addrconf_dad_start(ifp);
+			addrconf_dad_start(ifp, RTF_ADDRCONF|RTF_PREFIX_RT);
 		}

 		if (ifp) {
@@ -1588,7 +1588,7 @@

 	ifp = ipv6_add_addr(idev, pfx, plen, scope, IFA_F_PERMANENT);
 	if (!IS_ERR(ifp)) {
-		addrconf_dad_start(ifp);
+		addrconf_dad_start(ifp, 0);
 		in6_ifa_put(ifp);
 		return 0;
 	}
@@ -1763,7 +1763,7 @@

 	ifp = ipv6_add_addr(idev, addr, 64, IFA_LINK, IFA_F_PERMANENT);
 	if (!IS_ERR(ifp)) {
-		addrconf_dad_start(ifp);
+		addrconf_dad_start(ifp, 0);
 		in6_ifa_put(ifp);
 	}
 }
@@ -2002,8 +2002,7 @@
 		memset(&rtmsg, 0, sizeof(struct in6_rtmsg));
 		rtmsg.rtmsg_type = RTMSG_NEWROUTE;
 		rtmsg.rtmsg_metric = IP6_RT_PRIO_ADDRCONF;
-		rtmsg.rtmsg_flags = (RTF_ALLONLINK | RTF_ADDRCONF |
-				     RTF_DEFAULT | RTF_UP);
+		rtmsg.rtmsg_flags = (RTF_ALLONLINK | RTF_DEFAULT | RTF_UP);

 		rtmsg.rtmsg_ifindex = ifp->idev->dev->ifindex;

@@ -2017,7 +2016,7 @@
 /*
  *	Duplicate Address Detection
  */
-static void addrconf_dad_start(struct inet6_ifaddr *ifp)
+static void addrconf_dad_start(struct inet6_ifaddr *ifp, int flags)
 {
 	struct net_device *dev;
 	unsigned long rand_num;
@@ -2027,7 +2026,8 @@
 	addrconf_join_solict(dev, &ifp->addr);

 	if (ifp->prefix_len != 128 && (ifp->flags&IFA_F_PERMANENT))
-		addrconf_prefix_route(&ifp->addr, ifp->prefix_len, dev, 0, RTF_ADDRCONF);
+		addrconf_prefix_route(&ifp->addr, ifp->prefix_len, dev, 0,
+					flags);

 	net_srandom(ifp->addr.s6_addr32[3]);
 	rand_num = net_random() % (ifp->idev->cnf.rtr_solicit_delay ? : 1);
diff -ruN linux-2.6.0-test1.org/net/ipv6/route.c linux-2.6.0-test1.new/net/ipv6/route.c
--- linux-2.6.0-test1.org/net/ipv6/route.c	2003-07-13 20:36:42.000000000 -0700
+++ linux-2.6.0-test1.new/net/ipv6/route.c	2003-07-21 09:58:11.000000000 -0700
@@ -1452,13 +1452,20 @@
 			 struct in6_addr *src,
 			 int iif,
 			 int type, u32 pid, u32 seq,
-			 struct nlmsghdr *in_nlh)
+			 struct nlmsghdr *in_nlh, int prefix)
 {
 	struct rtmsg *rtm;
 	struct nlmsghdr  *nlh;
 	unsigned char	 *b = skb->tail;
 	struct rta_cacheinfo ci;

+	if (prefix) {	/* user wants prefix routes only */
+		if (!(rt->rt6i_flags & RTF_PREFIX_RT)) {
+			/* success since this is not a prefix route */
+			return 1;
+		}
+	}
+
 	if (!pid && in_nlh) {
 		pid = in_nlh->nlmsg_pid;
 	}
@@ -1539,10 +1546,17 @@
 static int rt6_dump_route(struct rt6_info *rt, void *p_arg)
 {
 	struct rt6_rtnl_dump_arg *arg = (struct rt6_rtnl_dump_arg *) p_arg;
+	struct rtmsg *rtm;
+	int prefix;
+
+	rtm = NLMSG_DATA(arg->cb->nlh);
+	if (rtm)
+		prefix = (rtm->rtm_flags & RTM_F_PREFIX) != 0;
+	else prefix = 0;

 	return rt6_fill_node(arg->skb, rt, NULL, NULL, 0, RTM_NEWROUTE,
 		     NETLINK_CB(arg->cb->skb).pid, arg->cb->nlh->nlmsg_seq,
-		     NULL);
+		     NULL, prefix);
 }

 static int fib6_dump_node(struct fib6_walker_t *w)
@@ -1690,7 +1704,7 @@
 			    &fl.fl6_dst, &fl.fl6_src,
 			    iif,
 			    RTM_NEWROUTE, NETLINK_CB(in_skb).pid,
-			    nlh->nlmsg_seq, nlh);
+			    nlh->nlmsg_seq, nlh, 0);
 	if (err < 0) {
 		err = -EMSGSIZE;
 		goto out_free;
@@ -1716,7 +1730,7 @@
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_ROUTE, ENOBUFS);
 		return;
 	}
-	if (rt6_fill_node(skb, rt, NULL, NULL, 0, event, 0, 0, nlh) < 0) {
+	if (rt6_fill_node(skb, rt, NULL, NULL, 0, event, 0, 0, nlh, 0) < 0) {
 		kfree_skb(skb);
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_ROUTE, EINVAL);
 		return;

^ permalink raw reply	[flat|nested] 52+ messages in thread

* O/M flags against 2.6.0-test1
  2003-07-21  1:55                       ` [PATCH 2/2] Prefix List and O/M flags against 2.4.21 kuznet
  2003-07-21  4:46                         ` David S. Miller
@ 2003-07-22 21:50                         ` Krishna Kumar
  2003-07-22 22:25                           ` YOSHIFUJI Hideaki / 吉藤英明
  2003-07-23 10:13                           ` David S. Miller
  2003-07-22 23:52                         ` [PATCH] Prefix List against 2.4.21 Krishna Kumar
  2 siblings, 2 replies; 52+ messages in thread
From: Krishna Kumar @ 2003-07-22 21:50 UTC (permalink / raw)
  To: kuznet; +Cc: yoshfuji, davem, netdev, linux-net, KK


> I don't have any knowledge of using this new interface.

<AK> Something like this.

Thanks Alexey, I have modelled the inet6 code on this. Hope this looks
good.

<AK> IFLA_INET6_CONF (and IFLA_INET_CONF). How to encode the values?
> Array of int's is simple, compact and looks good. But I have some
> problem with it. What if one day we want to implement changing the
> values? It will be nasty.

I think this is the simplest method. For changing, isn't it possible to
reverse the direction of memcpy back to the structure ? Ofcourse we need
to make sure the values are legal, or that a 'get' was done prior to the
'put', which does make it nasty.

<DM> Please let us to use some portable types instead of 'int' :-)

I am using sizeof(struct xxx) or __u32, etc in the code, I guess you are
ok with that.

I didn't add the statistics, though it can be implemented :
RTA_PUT(skb, IFLA_INET6_STATS, sizeof(idev->stats.icmpv6),
		&idev->stats.icmpv6[0]);
RTA_PUT(skb, IFLA_INET6_STATS, sizeof(idev->stats.icmpv6),
                &idev->stats.icmpv6[1]);
something like that would work ?

Thanks,

- KK

------------------------------------------------------------------------------
diff -ruN linux-2.6.0-test1.plist/include/linux/rtnetlink.h linux-2.6.0-test1.new/include/linux/rtnetlink.h
--- linux-2.6.0-test1.plist/include/linux/rtnetlink.h	2003-07-22 13:59:17.000000000 -0700
+++ linux-2.6.0-test1.new/include/linux/rtnetlink.h	2003-07-22 10:50:42.000000000 -0700
@@ -477,10 +477,12 @@
 #define IFLA_MASTER IFLA_MASTER
 	IFLA_WIRELESS,		/* Wireless Extension event - see wireless.h */
 #define IFLA_WIRELESS IFLA_WIRELESS
+	IFLA_PROTINFO,
+#define IFLA_PROTINFO IFLA_PROTINFO
 };


-#define IFLA_MAX IFLA_WIRELESS
+#define IFLA_MAX IFLA_PROTINFO

 #define IFLA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
 #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
@@ -514,6 +516,18 @@
    for IPIP tunnels, when route to endpoint is allowed to change)
  */

+/* Sub-attribute types for IFLA_PROTINFO */
+enum
+{
+	IFLA_INET6_UNSPEC,
+	IFLA_INET6_FLAGS,	/* link flags			*/
+	IFLA_INET6_CONF,	/* sysctl parameters		*/
+	IFLA_INET6_STATS,	/* statistics			*/
+	IFLA_INET6_MCAST,	/* MC things. What of them?	*/
+};
+
+#define IFLA_INET6_MAX	IFLA_INET6_MCAST
+
 /*****************************************************************
  *		Traffic control messages.
  ****/
diff -ruN linux-2.6.0-test1.plist/net/ipv6/addrconf.c linux-2.6.0-test1.new/net/ipv6/addrconf.c
--- linux-2.6.0-test1.plist/net/ipv6/addrconf.c	2003-07-22 13:59:17.000000000 -0700
+++ linux-2.6.0-test1.new/net/ipv6/addrconf.c	2003-07-22 13:55:07.000000000 -0700
@@ -2510,7 +2510,77 @@
 	netlink_broadcast(rtnl, skb, 0, RTMGRP_IPV6_IFADDR, GFP_ATOMIC);
 }

+static int inet6_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
+			    struct inet6_dev *idev,
+			    int type, u32 pid, u32 seq)
+{
+	struct ifinfomsg *r;
+	struct nlmsghdr  *nlh;
+	unsigned char	 *b = skb->tail;
+	struct rtattr	 *subattr;
+
+	nlh = NLMSG_PUT(skb, pid, seq, type, sizeof(*r));
+	if (pid) nlh->nlmsg_flags |= NLM_F_MULTI;
+	r = NLMSG_DATA(nlh);
+	r->ifi_family = AF_INET6;
+	r->ifi_type = dev->type;
+	r->ifi_index = dev->ifindex;
+	r->ifi_flags = dev->flags;
+	r->ifi_change = 0;
+	if (!netif_running(dev) || !netif_carrier_ok(dev))
+		r->ifi_flags &= ~IFF_RUNNING;
+	else
+		r->ifi_flags |= IFF_RUNNING;
+
+	RTA_PUT(skb, IFLA_IFNAME, strlen(dev->name)+1, dev->name);
+
+	subattr = (struct rtattr*)skb->tail;
+	RTA_PUT(skb, IFLA_PROTINFO, 0, NULL);
+	RTA_PUT(skb, IFLA_INET6_FLAGS, sizeof(__u32), &idev->if_flags);
+	/*
+	 * XXX	- any better way than using 'sizeof(struct) - n' below ?
+	 *	- stats/multicast not implemented
+	 */
+	RTA_PUT(skb, IFLA_INET6_CONF, sizeof(idev->cnf) - sizeof(void *),
+				&idev->cnf);
+	subattr->rta_len = skb->tail - (u8*)subattr;
+
+	nlh->nlmsg_len = skb->tail - b;
+	return skb->len;
+
+nlmsg_failure:
+rtattr_failure:
+	skb_trim(skb, b - skb->data);
+	return -1;
+}
+
+static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
+{
+	int idx, err;
+	int s_idx = cb->args[0];
+	struct net_device *dev;
+	struct inet6_dev *idev;
+
+	read_lock(&dev_base_lock);
+	for (dev=dev_base, idx=0; dev; dev = dev->next, idx++) {
+		if (idx < s_idx)
+			continue;
+		if ((idev = in6_dev_get(dev)) == NULL)
+			continue;
+		err = inet6_fill_ifinfo(skb, dev, idev, RTM_NEWLINK,
+				NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq);
+		in6_dev_put(idev);
+		if (err <= 0)
+			break;
+	}
+	read_unlock(&dev_base_lock);
+	cb->args[0] = idx;
+
+	return skb->len;
+}
+
 static struct rtnetlink_link inet6_rtnetlink_table[RTM_MAX - RTM_BASE + 1] = {
+	[RTM_GETLINK - RTM_BASE] = { .dumpit	= inet6_dump_ifinfo, },
 	[RTM_NEWADDR - RTM_BASE] = { .doit	= inet6_rtm_newaddr, },
 	[RTM_DELADDR - RTM_BASE] = { .doit	= inet6_rtm_deladdr, },
 	[RTM_GETADDR - RTM_BASE] = { .dumpit	= inet6_dump_ifaddr, },



^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: O/M flags against 2.6.0-test1
  2003-07-22 21:50                         ` O/M flags against 2.6.0-test1 Krishna Kumar
@ 2003-07-22 22:25                           ` YOSHIFUJI Hideaki / 吉藤英明
  2003-07-22 22:59                             ` Krishna Kumar
  2003-07-23 10:13                           ` David S. Miller
  1 sibling, 1 reply; 52+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2003-07-22 22:25 UTC (permalink / raw)
  To: krkumar; +Cc: kuznet, davem, netdev, linux-net

In article <Pine.LNX.4.44.0307221415140.14683-100000@DYN318430.beaverton.ibm.com> (at Tue, 22 Jul 2003 14:50:21 -0700 (PDT)), Krishna Kumar <krkumar@us.ibm.com> says:

> I didn't add the statistics, though it can be implemented :
> RTA_PUT(skb, IFLA_INET6_STATS, sizeof(idev->stats.icmpv6),
> 		&idev->stats.icmpv6[0]);
> RTA_PUT(skb, IFLA_INET6_STATS, sizeof(idev->stats.icmpv6),
>                 &idev->stats.icmpv6[1]);
> something like that would work ?

I'd like to do this later, if you don't mind.

--yoshfuji

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: O/M flags against 2.6.0-test1
  2003-07-22 22:25                           ` YOSHIFUJI Hideaki / 吉藤英明
@ 2003-07-22 22:59                             ` Krishna Kumar
  0 siblings, 0 replies; 52+ messages in thread
From: Krishna Kumar @ 2003-07-22 22:59 UTC (permalink / raw)
  To: YOSHIFUJI Hideaki / ????; +Cc: kuznet, davem, netdev, linux-net

I guess you are talking about the statistics part. This is fine with me.

thx,

- KK

YOSHIFUJI Hideaki / ???? wrote:
> In article <Pine.LNX.4.44.0307221415140.14683-100000@DYN318430.beaverton.ibm.com> (at Tue, 22 Jul 2003 14:50:21 -0700 (PDT)), Krishna Kumar <krkumar@us.ibm.com> says:
> 
> 
>>I didn't add the statistics, though it can be implemented :
>>RTA_PUT(skb, IFLA_INET6_STATS, sizeof(idev->stats.icmpv6),
>>		&idev->stats.icmpv6[0]);
>>RTA_PUT(skb, IFLA_INET6_STATS, sizeof(idev->stats.icmpv6),
>>                &idev->stats.icmpv6[1]);
>>something like that would work ?
> 
> 
> I'd like to do this later, if you don't mind.
> 
> --yoshfuji
> 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [PATCH] Prefix List against 2.4.21
  2003-07-21  1:55                       ` [PATCH 2/2] Prefix List and O/M flags against 2.4.21 kuznet
  2003-07-21  4:46                         ` David S. Miller
  2003-07-22 21:50                         ` O/M flags against 2.6.0-test1 Krishna Kumar
@ 2003-07-22 23:52                         ` Krishna Kumar
  2003-07-23 10:02                           ` David S. Miller
  2 siblings, 1 reply; 52+ messages in thread
From: Krishna Kumar @ 2003-07-22 23:52 UTC (permalink / raw)
  To: kuznet; +Cc: yoshfuji, davem, netdev

The same patch against 2.4.21.

thanks,

- KK

------------------------------------------------------------------------------

diff -ruN linux-2.4.21.org/include/linux/ipv6_route.h linux-2.4.21.new/include/linux/ipv6_route.h
--- linux-2.4.21.org/include/linux/ipv6_route.h	1998-08-27 19:33:08.000000000 -0700
+++ linux-2.4.21.new/include/linux/ipv6_route.h	2003-07-22 15:08:07.000000000 -0700
@@ -25,6 +25,7 @@
 #define RTF_DEFAULT	0x00010000	/* default - learned via ND	*/
 #define RTF_ALLONLINK	0x00020000	/* fallback, no routers on link	*/
 #define RTF_ADDRCONF	0x00040000	/* addrconf route - RA		*/
+#define RTF_PREFIX_RT	0x00080000	/* A prefix only route - RA	*/

 #define RTF_NONEXTHOP	0x00200000	/* route with no nexthop	*/
 #define RTF_EXPIRES	0x00400000
diff -ruN linux-2.4.21.org/include/linux/rtnetlink.h linux-2.4.21.new/include/linux/rtnetlink.h
--- linux-2.4.21.org/include/linux/rtnetlink.h	2002-11-28 15:53:15.000000000 -0800
+++ linux-2.4.21.new/include/linux/rtnetlink.h	2003-07-22 15:08:35.000000000 -0700
@@ -167,6 +167,7 @@
 #define RTM_F_NOTIFY		0x100	/* Notify user of route change	*/
 #define RTM_F_CLONED		0x200	/* This route is cloned		*/
 #define RTM_F_EQUALIZE		0x400	/* Multipath equalizer: NI	*/
+#define RTM_F_PREFIX		0x800	/* Prefix addresses		*/

 /* Reserved table identifiers */

diff -ruN linux-2.4.21.org/net/ipv6/addrconf.c linux-2.4.21.new/net/ipv6/addrconf.c
--- linux-2.4.21.org/net/ipv6/addrconf.c	2003-06-13 07:51:39.000000000 -0700
+++ linux-2.4.21.new/net/ipv6/addrconf.c	2003-07-22 15:13:53.000000000 -0700
@@ -101,7 +101,7 @@

 static int addrconf_ifdown(struct net_device *dev, int how);

-static void addrconf_dad_start(struct inet6_ifaddr *ifp);
+static void addrconf_dad_start(struct inet6_ifaddr *ifp, int flags);
 static void addrconf_dad_timer(unsigned long data);
 static void addrconf_dad_completed(struct inet6_ifaddr *ifp);
 static void addrconf_rs_timer(unsigned long data);
@@ -889,7 +889,7 @@
 	rtmsg.rtmsg_dst_len = 8;
 	rtmsg.rtmsg_metric = IP6_RT_PRIO_ADDRCONF;
 	rtmsg.rtmsg_ifindex = dev->ifindex;
-	rtmsg.rtmsg_flags = RTF_UP|RTF_ADDRCONF;
+	rtmsg.rtmsg_flags = RTF_UP;
 	rtmsg.rtmsg_type = RTMSG_NEWROUTE;
 	ip6_route_add(&rtmsg, NULL);
 }
@@ -916,7 +916,7 @@
 	struct in6_addr addr;

 	ipv6_addr_set(&addr,  htonl(0xFE800000), 0, 0, 0);
-	addrconf_prefix_route(&addr, 64, dev, 0, RTF_ADDRCONF);
+	addrconf_prefix_route(&addr, 64, dev, 0, 0);
 }

 static struct inet6_dev *addrconf_add_dev(struct net_device *dev)
@@ -1008,7 +1008,7 @@
 		}
 	} else if (pinfo->onlink && valid_lft) {
 		addrconf_prefix_route(&pinfo->prefix, pinfo->prefix_len,
-				      dev, rt_expires, RTF_ADDRCONF|RTF_EXPIRES);
+				      dev, rt_expires, RTF_ADDRCONF|RTF_EXPIRES|RTF_PREFIX_RT);
 	}
 	if (rt)
 		dst_release(&rt->u.dst);
@@ -1054,7 +1054,7 @@
 				return;
 			}

-			addrconf_dad_start(ifp);
+			addrconf_dad_start(ifp, RTF_ADDRCONF|RTF_PREFIX_RT);
 		}

 		if (ifp && valid_lft == 0) {
@@ -1166,7 +1166,7 @@

 	ifp = ipv6_add_addr(idev, pfx, plen, scope, IFA_F_PERMANENT);
 	if (!IS_ERR(ifp)) {
-		addrconf_dad_start(ifp);
+		addrconf_dad_start(ifp, 0);
 		in6_ifa_put(ifp);
 		return 0;
 	}
@@ -1341,7 +1341,7 @@

 	ifp = ipv6_add_addr(idev, addr, 64, IFA_LINK, IFA_F_PERMANENT);
 	if (!IS_ERR(ifp)) {
-		addrconf_dad_start(ifp);
+		addrconf_dad_start(ifp, 0);
 		in6_ifa_put(ifp);
 	}
 }
@@ -1578,8 +1578,7 @@
 		memset(&rtmsg, 0, sizeof(struct in6_rtmsg));
 		rtmsg.rtmsg_type = RTMSG_NEWROUTE;
 		rtmsg.rtmsg_metric = IP6_RT_PRIO_ADDRCONF;
-		rtmsg.rtmsg_flags = (RTF_ALLONLINK | RTF_ADDRCONF |
-				     RTF_DEFAULT | RTF_UP);
+		rtmsg.rtmsg_flags = (RTF_ALLONLINK | RTF_DEFAULT | RTF_UP);

 		rtmsg.rtmsg_ifindex = ifp->idev->dev->ifindex;

@@ -1593,7 +1592,7 @@
 /*
  *	Duplicate Address Detection
  */
-static void addrconf_dad_start(struct inet6_ifaddr *ifp)
+static void addrconf_dad_start(struct inet6_ifaddr *ifp, int flags)
 {
 	struct net_device *dev;
 	unsigned long rand_num;
@@ -1603,7 +1602,7 @@
 	addrconf_join_solict(dev, &ifp->addr);

 	if (ifp->prefix_len != 128 && (ifp->flags&IFA_F_PERMANENT))
-		addrconf_prefix_route(&ifp->addr, ifp->prefix_len, dev, 0, RTF_ADDRCONF);
+		addrconf_prefix_route(&ifp->addr, ifp->prefix_len, dev, 0, flags);

 	net_srandom(ifp->addr.s6_addr32[3]);
 	rand_num = net_random() % (ifp->idev->cnf.rtr_solicit_delay ? : 1);
diff -ruN linux-2.4.21.org/net/ipv6/route.c linux-2.4.21.new/net/ipv6/route.c
--- linux-2.4.21.org/net/ipv6/route.c	2003-06-13 07:51:39.000000000 -0700
+++ linux-2.4.21.new/net/ipv6/route.c	2003-07-22 15:15:56.000000000 -0700
@@ -1516,13 +1516,19 @@
 			 struct in6_addr *src,
 			 int iif,
 			 int type, u32 pid, u32 seq,
-			 struct nlmsghdr *in_nlh)
+			 struct nlmsghdr *in_nlh, int prefix)
 {
 	struct rtmsg *rtm;
 	struct nlmsghdr  *nlh;
 	unsigned char	 *b = skb->tail;
 	struct rta_cacheinfo ci;

+	if (prefix) {	/* user wants prefix routes only */
+		if (!(rt->rt6i_flags & RTF_PREFIX_RT)) {
+			/* success since this is not a prefix route */
+			return 1;
+		}
+	}
 	if (!pid && in_nlh) {
 		pid = in_nlh->nlmsg_pid;
 	}
@@ -1603,10 +1609,17 @@
 static int rt6_dump_route(struct rt6_info *rt, void *p_arg)
 {
 	struct rt6_rtnl_dump_arg *arg = (struct rt6_rtnl_dump_arg *) p_arg;
+	struct rtmsg *rtm;
+	int prefix;
+
+	rtm = NLMSG_DATA(arg->cb->nlh);
+	if (rtm)
+		prefix = (rtm->rtm_flags & RTM_F_PREFIX) != 0;
+	else prefix = 0;

 	return rt6_fill_node(arg->skb, rt, NULL, NULL, 0, RTM_NEWROUTE,
 		     NETLINK_CB(arg->cb->skb).pid, arg->cb->nlh->nlmsg_seq,
-		     NULL);
+		     NULL, prefix);
 }

 static int fib6_dump_node(struct fib6_walker_t *w)
@@ -1757,7 +1770,7 @@
 			    fl.nl_u.ip6_u.saddr,
 			    iif,
 			    RTM_NEWROUTE, NETLINK_CB(in_skb).pid,
-			    nlh->nlmsg_seq, nlh);
+			    nlh->nlmsg_seq, nlh, 0);
 	if (err < 0) {
 		err = -EMSGSIZE;
 		goto out_free;
@@ -1783,7 +1796,7 @@
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_ROUTE, ENOBUFS);
 		return;
 	}
-	if (rt6_fill_node(skb, rt, NULL, NULL, 0, event, 0, 0, nlh) < 0) {
+	if (rt6_fill_node(skb, rt, NULL, NULL, 0, event, 0, 0, nlh, 0) < 0) {
 		kfree_skb(skb);
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_ROUTE, EINVAL);
 		return;

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH] Prefix List against 2.4.21
  2003-07-22 23:52                         ` [PATCH] Prefix List against 2.4.21 Krishna Kumar
@ 2003-07-23 10:02                           ` David S. Miller
  0 siblings, 0 replies; 52+ messages in thread
From: David S. Miller @ 2003-07-23 10:02 UTC (permalink / raw)
  To: Krishna Kumar; +Cc: kuznet, yoshfuji, netdev

On Tue, 22 Jul 2003 16:52:24 -0700 (PDT)
Krishna Kumar <krkumar@us.ibm.com> wrote:

> The same patch against 2.4.21.

I've applied both 2.5.x and 2.4.x patches.  Thanks.

On the 2.4.x side, Marcelo is only accepting bug fixes so
this prefix list stuff will have to wait for 2.4.23-pre1
before going in.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: O/M flags against 2.6.0-test1
  2003-07-22 21:50                         ` O/M flags against 2.6.0-test1 Krishna Kumar
  2003-07-22 22:25                           ` YOSHIFUJI Hideaki / 吉藤英明
@ 2003-07-23 10:13                           ` David S. Miller
  2003-07-23 22:32                             ` Krishna Kumar
  1 sibling, 1 reply; 52+ messages in thread
From: David S. Miller @ 2003-07-23 10:13 UTC (permalink / raw)
  To: Krishna Kumar; +Cc: kuznet, yoshfuji, netdev, linux-net, krkumar

On Tue, 22 Jul 2003 14:50:21 -0700 (PDT)
Krishna Kumar <krkumar@us.ibm.com> wrote:

> I am using sizeof(struct xxx) or __u32, etc in the code, I guess you are
> ok with that.

This needs some fixes still.  First thing, ipv6_devconf is not
obtainable from user and has pointers in it which makes usage sloppy.
So I would suggest the following:

1) Remove "void *sysctl;" from ipv6_devconf, move it into
   inet6_dev ie. "void *cnf_sysctl;" update all code users.

2) Move "struct ipv6_devconf" into some linux/*.h ipv6 header
   usable by users.  Use an existing one if possible.  Then
   make sure net/if_inet6.h includes this thing.

3) Change "int" members of struct "ipv6_devconf" to "s32".
   It's anal and unnecessary on any current platform, but
   some day with 128-bit computers it might make some difference.
   :-)

Thanks.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: O/M flags against 2.6.0-test1
  2003-07-23 10:13                           ` David S. Miller
@ 2003-07-23 22:32                             ` Krishna Kumar
  2003-07-24  7:07                               ` David S. Miller
  0 siblings, 1 reply; 52+ messages in thread
From: Krishna Kumar @ 2003-07-23 22:32 UTC (permalink / raw)
  To: David S. Miller; +Cc: kuznet, yoshfuji, netdev

Hi Dave,

> 1) Remove "void *sysctl;" from ipv6_devconf, move it into
>    inet6_dev ie. "void *cnf_sysctl;" update all code users.

There is one problem with this that I am not able to figure out, perhaps I am
overlooking it. addrconf_sysctl_register() gets called for ipv6_devconf_dflt,
but there is no inet6_dev for this configuration, so is it possible to move the
sysctl up (there is no 'up' :-). I don't want to create a dummy inet6_dev for
this. One way is to embed the actual config structure as follows :

struct ipv6_devconf {
	void *sysctl;
	struct {
		forwarding;
		hop_limit;
		...
	} u;
};
and follow it up with #defines for all the elements, etc. Then I can use
sizeof(ipv6_devconf.u) without this problem. Another way to do this is using
pointer arithmetic :
	RTA_PUT(skb, IFLA_INET6_CONF, &idev->cnf.sysctl-&idev->cnf.forwarding,
			&idev->cnf);
(guess you may not like it based on your statement "pointers in it which makes
usage sloppy").

I also noticed there is no sysctl_register for ipv6_devconf, but there is a
unregister for that conf. Is that correct ?

> 2) Move "struct ipv6_devconf" into some linux/*.h ipv6 header
>    usable by users.  Use an existing one if possible.  Then
>    make sure net/if_inet6.h includes this thing.

The only two ipv6 specific files in linux are ipv6.h and ipv6_route.h, neither
are appropriate for sysctl stuff I think. So should I create a new file like the
one for ipv4_devconf exists in inetdevice.h ?

> 3) Change "int" members of struct "ipv6_devconf" to "s32".

All members (except use_tempaddr) seem to be >=0, should I change the definition
to __u32 instead ? I am OK either way, just wondering which is the right way to
do this.

Thanks,

- KK

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: O/M flags against 2.6.0-test1
  2003-07-23 22:32                             ` Krishna Kumar
@ 2003-07-24  7:07                               ` David S. Miller
  2003-07-24 14:02                                 ` kuznet
  2003-07-30  0:33                                 ` Krishna Kumar
  0 siblings, 2 replies; 52+ messages in thread
From: David S. Miller @ 2003-07-24  7:07 UTC (permalink / raw)
  To: Krishna Kumar; +Cc: kuznet, yoshfuji, netdev

On Wed, 23 Jul 2003 15:32:23 -0700
Krishna Kumar <krkumar@us.ibm.com> wrote:

> > 1) Remove "void *sysctl;" from ipv6_devconf, move it into
> >    inet6_dev ie. "void *cnf_sysctl;" update all code users.
> 
> There is one problem with this that I am not able to figure out, perhaps I am
> overlooking it. addrconf_sysctl_register() gets called for ipv6_devconf_dflt,
> but there is no inet6_dev for this configuration, so is it possible to move the
> sysctl up (there is no 'up' :-). I don't want to create a dummy inet6_dev for
> this. One way is to embed the actual config structure as follows :

Another idea is to define the user structure:

struct ipv6_user_devconf {
	__u32 forwarding;
...
};

Then:

struct ipv6_kernel_devconf {
	struct ipv6_user_devconf vals;
	void *sysctl;
};

It is similar to what you suggest.

> > 2) Move "struct ipv6_devconf" into some linux/*.h ipv6 header
> >    usable by users.  Use an existing one if possible.  Then
> >    make sure net/if_inet6.h includes this thing.
> 
> The only two ipv6 specific files in linux are ipv6.h and
> ipv6_route.h, neither are appropriate for sysctl stuff I think. So
> should I create a new file like the one for ipv4_devconf exists in
> inetdevice.h ?

I see no reason why ipv6.h is a bad place, heck we have
an in6_ifreq there already.

> > 3) Change "int" members of struct "ipv6_devconf" to "s32".
> 
> All members (except use_tempaddr) seem to be >=0, should I change
> the definition to __u32 instead ?

__u32 sounds fine.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: O/M flags against 2.6.0-test1
  2003-07-24  7:07                               ` David S. Miller
@ 2003-07-24 14:02                                 ` kuznet
  2003-07-24 14:26                                   ` YOSHIFUJI Hideaki / 吉藤英明
  2003-07-30  0:33                                 ` Krishna Kumar
  1 sibling, 1 reply; 52+ messages in thread
From: kuznet @ 2003-07-24 14:02 UTC (permalink / raw)
  To: David S. Miller; +Cc: krkumar, yoshfuji, netdev

Hello!

> Another idea is to define the user structure:

Actually, I saw it just as array indexed by values from sysctl.h.

Maybe, struct is better, but I am inclined to think in this case it is wrong.
It is going to be extended, so newly compiled applications will see
truncated structs from older kernels and will have to do ugly job
verifying validity of fields using some offsetof. In the case of array
it is natural at least.

Alexey

PS I know right way is not to change the struct. :-)
It is another reason why I am still not sure that encoding
sysctl values as separate subattributes is bad idea.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: O/M flags against 2.6.0-test1
  2003-07-24 14:02                                 ` kuznet
@ 2003-07-24 14:26                                   ` YOSHIFUJI Hideaki / 吉藤英明
  2003-07-24 14:43                                     ` kuznet
  0 siblings, 1 reply; 52+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2003-07-24 14:26 UTC (permalink / raw)
  To: kuznet; +Cc: davem, krkumar, netdev, yoshfuji

In article <200307241402.SAA09143@dub.inr.ac.ru> (at Thu, 24 Jul 2003 18:02:35 +0400 (MSD)), kuznet@ms2.inr.ac.ru says:

> Maybe, struct is better, but I am inclined to think in this case it is wrong.
> It is going to be extended, so newly compiled applications will see
> truncated structs from older kernels and will have to do ugly job
> verifying validity of fields using some offsetof. In the case of array
> it is natural at least.

I'm not so sure about the "array," but anyway,
I don't think it is so ugly to use struct / offsetof.

--yoshfuji

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: O/M flags against 2.6.0-test1
  2003-07-24 14:26                                   ` YOSHIFUJI Hideaki / 吉藤英明
@ 2003-07-24 14:43                                     ` kuznet
  2003-07-25  0:14                                       ` Krishna Kumar
  0 siblings, 1 reply; 52+ messages in thread
From: kuznet @ 2003-07-24 14:43 UTC (permalink / raw)
  To: YOSHIFUJIHideaki/吉藤英明
  Cc: davem, krkumar, netdev, yoshfuji

Hello!

> I'm not so sure about the "array," but anyway,
> I don't think it is so ugly to use struct / offsetof.

Just write a sample of code, printing all fields of struct
and equivalent array, and you will see.

Well, I just know, that when iproute will do this, it will
cast the struct to array in any case. It is dirty, but sane at least. :-)

Alexey

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: O/M flags against 2.6.0-test1
  2003-07-24 14:43                                     ` kuznet
@ 2003-07-25  0:14                                       ` Krishna Kumar
  2003-07-25 13:22                                         ` David S. Miller
  0 siblings, 1 reply; 52+ messages in thread
From: Krishna Kumar @ 2003-07-25  0:14 UTC (permalink / raw)
  To: kuznet; +Cc: yoshfuji, davem, netdev

So people are ok with using struct ? Since it can be typecast as an array :-)

thanks,

- KK


kuznet@ms2.inr.ac.ru wrote:
> Hello!
> 
> 
>>I'm not so sure about the "array," but anyway,
>>I don't think it is so ugly to use struct / offsetof.
> 
> 
> Just write a sample of code, printing all fields of struct
> and equivalent array, and you will see.
> 
> Well, I just know, that when iproute will do this, it will
> cast the struct to array in any case. It is dirty, but sane at least. :-)
> 
> Alexey
> 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: O/M flags against 2.6.0-test1
  2003-07-25  0:14                                       ` Krishna Kumar
@ 2003-07-25 13:22                                         ` David S. Miller
  0 siblings, 0 replies; 52+ messages in thread
From: David S. Miller @ 2003-07-25 13:22 UTC (permalink / raw)
  To: Krishna Kumar; +Cc: kuznet, yoshfuji, netdev

On Thu, 24 Jul 2003 17:14:36 -0700
Krishna Kumar <krkumar@us.ibm.com> wrote:

> So people are ok with using struct ? Since it can be typecast as an array :-)

I think something more like route metrics, ie. an array,
is more appropriate and that Alexey is right about this.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: O/M flags against 2.6.0-test1
  2003-07-24  7:07                               ` David S. Miller
  2003-07-24 14:02                                 ` kuznet
@ 2003-07-30  0:33                                 ` Krishna Kumar
  2003-07-31  5:02                                   ` David S. Miller
  1 sibling, 1 reply; 52+ messages in thread
From: Krishna Kumar @ 2003-07-30  0:33 UTC (permalink / raw)
  To: David S. Miller; +Cc: kuznet, yoshfuji, netdev


> Another idea is to define the user structure:
>
> struct ipv6_kernel_devconf {
> 	struct ipv6_user_devconf vals;
> 	void *sysctl;
> };

After the latest suggestion to use array instead of a structure,
the patch being submitted doesn't make this change. I hope that is
acceptable.

> > > 3) Change "int" members of struct "ipv6_devconf" to "s32".
> >
> > All members (except use_tempaddr) seem to be >=0, should I change
> > the definition to __u32 instead ?
>
> __u32 sounds fine.

Since use_tempaddr can be -1, I am for the time being keeping all
the variables as s32. If this is changed to __u32, then some code in
addrconf.c needs to be modified.

> I think something more like route metrics, ie. an array is more appropriate

I guess you mean only the user interface to use route type metrics, not
modify the existing cnf implementation to use this concept (eg remove the
structure and define cnf_metrics[] with code similar to RTAX_HOPLIMIT,
etc). So this patch doesn't change the usage in kernel, except now the
user interface returns the config params in an array format.

This patch applies on top of the prefix list patch.

Thanks,

- KK

PS : Alexey's patch for ipv4 defines IFLA_INET_MAX as IFLA_INET_CONF,
probably that should be IFLA_INET_MCAST. Another thing that confused me
is that there is no addrconf_sysctl_register for ipv6_devconf, while it
is being unregister'd (which would fail?).

------------------------------------------------------------------------------
diff -ruN 1/linux-2.6.0-test1.plist/include/linux/ipv6.h linux-2.6.0-test1.new/include/linux/ipv6.h
--- 1/linux-2.6.0-test1.plist/include/linux/ipv6.h	2003-07-13 20:36:33.000000000 -0700
+++ linux-2.6.0-test1.new/include/linux/ipv6.h	2003-07-29 17:02:57.000000000 -0700
@@ -122,6 +122,30 @@
 	struct	in6_addr	daddr;
 };

+/*
+ * This structure contains configuration options per IPv6 link.
+ */
+struct ipv6_devconf {
+	s32		forwarding;
+	s32		hop_limit;
+	s32		mtu6;
+	s32		accept_ra;
+	s32		accept_redirects;
+	s32		autoconf;
+	s32		dad_transmits;
+	s32		rtr_solicits;
+	s32		rtr_solicit_interval;
+	s32		rtr_solicit_delay;
+#ifdef CONFIG_IPV6_PRIVACY
+	s32		use_tempaddr;
+	s32		temp_valid_lft;
+	s32		temp_prefered_lft;
+	s32		regen_max_retry;
+	s32		max_desync_factor;
+#endif
+	void		*sysctl;
+};
+
 #ifdef __KERNEL__
 #include <linux/in6.h>          /* struct sockaddr_in6 */
 #include <linux/icmpv6.h>
diff -ruN 1/linux-2.6.0-test1.plist/include/linux/rtnetlink.h linux-2.6.0-test1.new/include/linux/rtnetlink.h
--- 1/linux-2.6.0-test1.plist/include/linux/rtnetlink.h	2003-07-29 12:05:26.000000000 -0700
+++ linux-2.6.0-test1.new/include/linux/rtnetlink.h	2003-07-29 14:49:16.000000000 -0700
@@ -477,10 +477,12 @@
 #define IFLA_MASTER IFLA_MASTER
 	IFLA_WIRELESS,		/* Wireless Extension event - see wireless.h */
 #define IFLA_WIRELESS IFLA_WIRELESS
+	IFLA_PROTINFO,		/* Protocol specific information per link */
+#define IFLA_PROTINFO IFLA_PROTINFO
 };


-#define IFLA_MAX IFLA_WIRELESS
+#define IFLA_MAX IFLA_PROTINFO

 #define IFLA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
 #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
@@ -514,6 +516,18 @@
    for IPIP tunnels, when route to endpoint is allowed to change)
  */

+/* Subtype attributes for IFLA_PROTINFO */
+enum
+{
+	IFLA_INET6_UNSPEC,
+	IFLA_INET6_FLAGS,	/* link flags			*/
+	IFLA_INET6_CONF,	/* sysctl parameters		*/
+	IFLA_INET6_STATS,	/* statistics			*/
+	IFLA_INET6_MCAST,	/* MC things. What of them?	*/
+};
+
+#define IFLA_INET6_MAX	IFLA_INET6_MCAST
+
 /*****************************************************************
  *		Traffic control messages.
  ****/
diff -ruN 1/linux-2.6.0-test1.plist/include/net/if_inet6.h linux-2.6.0-test1.new/include/net/if_inet6.h
--- 1/linux-2.6.0-test1.plist/include/net/if_inet6.h	2003-07-13 20:38:43.000000000 -0700
+++ linux-2.6.0-test1.new/include/net/if_inet6.h	2003-07-29 16:28:56.000000000 -0700
@@ -16,6 +16,7 @@
 #define _NET_IF_INET6_H

 #include <net/snmp.h>
+#include <linux/ipv6.h>

 #define IF_RA_RCVD	0x20
 #define IF_RS_SENT	0x10
@@ -132,28 +133,6 @@
 #define	IFA_SITE	IPV6_ADDR_SITELOCAL
 #define	IFA_GLOBAL	0x0000U

-struct ipv6_devconf
-{
-	int		forwarding;
-	int		hop_limit;
-	int		mtu6;
-	int		accept_ra;
-	int		accept_redirects;
-	int		autoconf;
-	int		dad_transmits;
-	int		rtr_solicits;
-	int		rtr_solicit_interval;
-	int		rtr_solicit_delay;
-#ifdef CONFIG_IPV6_PRIVACY
-	int		use_tempaddr;
-	int		temp_valid_lft;
-	int		temp_prefered_lft;
-	int		regen_max_retry;
-	int		max_desync_factor;
-#endif
-	void		*sysctl;
-};
-
 struct ipv6_devstat {
 	struct proc_dir_entry	*proc_dir_entry;
 	DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6);
diff -ruN 1/linux-2.6.0-test1.plist/net/ipv6/addrconf.c linux-2.6.0-test1.new/net/ipv6/addrconf.c
--- 1/linux-2.6.0-test1.plist/net/ipv6/addrconf.c	2003-07-29 12:05:26.000000000 -0700
+++ linux-2.6.0-test1.new/net/ipv6/addrconf.c	2003-07-29 15:54:42.000000000 -0700
@@ -2510,7 +2510,112 @@
 	netlink_broadcast(rtnl, skb, 0, RTMGRP_IPV6_IFADDR, GFP_ATOMIC);
 }

+static int inline ipv6_store_devconf(struct ipv6_devconf *cnf, int *array)
+{
+	int i = 0;
+
+	array[i++] = cnf->forwarding;
+	array[i++] = cnf->hop_limit;
+	array[i++] = cnf->mtu6;
+	array[i++] = cnf->accept_ra;
+	array[i++] = cnf->accept_redirects;
+	array[i++] = cnf->autoconf;
+	array[i++] = cnf->dad_transmits;
+	array[i++] = cnf->rtr_solicits;
+	array[i++] = cnf->rtr_solicit_interval;
+	array[i++] = cnf->rtr_solicit_delay;
+#ifdef CONFIG_IPV6_PRIVACY
+	array[i++] = cnf->use_tempaddr;
+	array[i++] = cnf->temp_valid_lft;
+	array[i++] = cnf->temp_prefered_lft;
+	array[i++] = cnf->regen_max_retry;
+	array[i++] = cnf->max_desync_factor;
+#endif
+	return i;	/* actual number of elements */
+}
+
+static int inet6_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
+			    struct inet6_dev *idev,
+			    int type, u32 pid, u32 seq)
+{
+	int			num_items;
+	int			*array = NULL;
+	struct ifinfomsg	*r;
+	struct nlmsghdr 	*nlh;
+	unsigned char		*b = skb->tail;
+	struct rtattr		*subattr;
+
+	nlh = NLMSG_PUT(skb, pid, seq, type, sizeof(*r));
+	if (pid) nlh->nlmsg_flags |= NLM_F_MULTI;
+	r = NLMSG_DATA(nlh);
+	r->ifi_family = AF_INET6;
+	r->ifi_type = dev->type;
+	r->ifi_index = dev->ifindex;
+	r->ifi_flags = dev->flags;
+	r->ifi_change = 0;
+	if (!netif_running(dev) || !netif_carrier_ok(dev))
+		r->ifi_flags &= ~IFF_RUNNING;
+	else
+		r->ifi_flags |= IFF_RUNNING;
+
+	RTA_PUT(skb, IFLA_IFNAME, strlen(dev->name)+1, dev->name);
+
+	subattr = (struct rtattr*)skb->tail;
+
+	RTA_PUT(skb, IFLA_PROTINFO, 0, NULL);
+	RTA_PUT(skb, IFLA_INET6_FLAGS, sizeof(__u32), &idev->if_flags);
+
+	/*
+	 * using sizeof(struct) can be wrong due to padding, but it is the
+	 * the maximum possible number of items, which gets corrected later.
+	 */
+	num_items = sizeof(struct ipv6_devconf) / sizeof(*array);
+	if ((array = kmalloc(num_items, GFP_KERNEL)) == NULL)
+		goto rtattr_failure;
+	num_items = ipv6_store_devconf(&idev->cnf, array);
+	RTA_PUT(skb, IFLA_INET6_CONF, num_items * sizeof(*array), array);
+	/* XXX stats/MC not implemented */
+	subattr->rta_len = skb->tail - (u8*)subattr;
+
+	nlh->nlmsg_len = skb->tail - b;
+	kfree(array);
+	return skb->len;
+
+nlmsg_failure:
+rtattr_failure:
+	if (array)
+		kfree(array);
+	skb_trim(skb, b - skb->data);
+	return -1;
+}
+
+static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
+{
+	int idx, err;
+	int s_idx = cb->args[0];
+	struct net_device *dev;
+	struct inet6_dev *idev;
+
+	read_lock(&dev_base_lock);
+	for (dev=dev_base, idx=0; dev; dev = dev->next, idx++) {
+		if (idx < s_idx)
+			continue;
+		if ((idev = in6_dev_get(dev)) == NULL)
+			continue;
+		err = inet6_fill_ifinfo(skb, dev, idev, RTM_NEWLINK,
+				NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq);
+		in6_dev_put(idev);
+		if (err <= 0)
+			break;
+	}
+	read_unlock(&dev_base_lock);
+	cb->args[0] = idx;
+
+	return skb->len;
+}
+
 static struct rtnetlink_link inet6_rtnetlink_table[RTM_MAX - RTM_BASE + 1] = {
+	[RTM_GETLINK - RTM_BASE] = { .dumpit	= inet6_dump_ifinfo, },
 	[RTM_NEWADDR - RTM_BASE] = { .doit	= inet6_rtm_newaddr, },
 	[RTM_DELADDR - RTM_BASE] = { .doit	= inet6_rtm_deladdr, },
 	[RTM_GETADDR - RTM_BASE] = { .dumpit	= inet6_dump_ifaddr, },

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: O/M flags against 2.6.0-test1
  2003-07-30  0:33                                 ` Krishna Kumar
@ 2003-07-31  5:02                                   ` David S. Miller
  2003-07-31 20:33                                     ` Krishna Kumar
  0 siblings, 1 reply; 52+ messages in thread
From: David S. Miller @ 2003-07-31  5:02 UTC (permalink / raw)
  To: Krishna Kumar; +Cc: kuznet, yoshfuji, netdev

On Tue, 29 Jul 2003 17:33:03 -0700 (PDT)
Krishna Kumar <krkumar@us.ibm.com> wrote:

> Since use_tempaddr can be -1, I am for the time being keeping all
> the variables as s32. If this is changed to __u32, then some code in
> addrconf.c needs to be modified.

Ok, but then please use "__s32".

> > I think something more like route metrics, ie. an array is more appropriate
> 
> I guess you mean only the user interface to use route type metrics, not
> modify the existing cnf implementation to use this concept (eg remove the
> structure and define cnf_metrics[] with code similar to RTAX_HOPLIMIT,
> etc). So this patch doesn't change the usage in kernel, except now the
> user interface returns the config params in an array format.
> 
> This patch applies on top of the prefix list patch.

I like the array scheme, but please you must define macros
(like RTAX_*) that give meaning to the array[] indices.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: O/M flags against 2.6.0-test1
  2003-07-31  5:02                                   ` David S. Miller
@ 2003-07-31 20:33                                     ` Krishna Kumar
  2003-08-04 23:57                                       ` David S. Miller
  0 siblings, 1 reply; 52+ messages in thread
From: Krishna Kumar @ 2003-07-31 20:33 UTC (permalink / raw)
  To: David S. Miller; +Cc: kuznet, yoshfuji, netdev, KK


> Ok, but then please use "__s32".

OK, slowly getting there :-)

Latest patch follows :

Thanks,

- KK

-------------------------------------------------------------------------------
diff -ruN linux-2.6.0-test1.plist/include/linux/ipv6.h linux-2.6.0-test1.new/include/linux/ipv6.h
--- linux-2.6.0-test1.plist/include/linux/ipv6.h	2003-07-13 20:36:33.000000000 -0700
+++ linux-2.6.0-test1.new/include/linux/ipv6.h	2003-07-31 11:20:48.000000000 -0700
@@ -122,6 +122,52 @@
 	struct	in6_addr	daddr;
 };

+/*
+ * This structure contains configuration options per IPv6 link.
+ */
+struct ipv6_devconf {
+	__s32		forwarding;
+	__s32		hop_limit;
+	__s32		mtu6;
+	__s32		accept_ra;
+	__s32		accept_redirects;
+	__s32		autoconf;
+	__s32		dad_transmits;
+	__s32		rtr_solicits;
+	__s32		rtr_solicit_interval;
+	__s32		rtr_solicit_delay;
+#ifdef CONFIG_IPV6_PRIVACY
+	__s32		use_tempaddr;
+	__s32		temp_valid_lft;
+	__s32		temp_prefered_lft;
+	__s32		regen_max_retry;
+	__s32		max_desync_factor;
+#endif
+	void		*sysctl;
+};
+
+/* index values for the variables in ipv6_devconf */
+enum {
+	DEVCONF_FORWARDING = 0,
+	DEVCONF_HOPLIMIT,
+	DEVCONF_MTU6,
+	DEVCONF_ACCEPT_RA,
+	DEVCONF_ACCEPT_REDIRECTS,
+	DEVCONF_AUTOCONF,
+	DEVCONF_DAD_TRANSMITS,
+	DEVCONF_RTR_SOLICITS,
+	DEVCONF_RTR_SOLICIT_INTERVAL,
+	DEVCONF_RTR_SOLICIT_DELAY,
+#ifdef CONFIG_IPV6_PRIVACY
+	DEVCONF_USE_TEMPADDR,
+	DEVCONF_TEMP_VALID_LFT,
+	DEVCONF_TEMP_PREFERED_LFT,
+	DEVCONF_REGEN_MAX_RETRY,
+	DEVCONF_MAX_DESYNC_FACTOR,
+#endif
+	DEVCONF_MAX
+};
+
 #ifdef __KERNEL__
 #include <linux/in6.h>          /* struct sockaddr_in6 */
 #include <linux/icmpv6.h>
diff -ruN linux-2.6.0-test1.plist/include/linux/rtnetlink.h linux-2.6.0-test1.new/include/linux/rtnetlink.h
--- linux-2.6.0-test1.plist/include/linux/rtnetlink.h	2003-07-31 12:00:39.000000000 -0700
+++ linux-2.6.0-test1.new/include/linux/rtnetlink.h	2003-07-31 11:30:57.000000000 -0700
@@ -477,10 +477,12 @@
 #define IFLA_MASTER IFLA_MASTER
 	IFLA_WIRELESS,		/* Wireless Extension event - see wireless.h */
 #define IFLA_WIRELESS IFLA_WIRELESS
+	IFLA_PROTINFO,		/* Protocol specific information for a link */
+#define IFLA_PROTINFO IFLA_PROTINFO
 };


-#define IFLA_MAX IFLA_WIRELESS
+#define IFLA_MAX IFLA_PROTINFO

 #define IFLA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
 #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
@@ -514,6 +516,18 @@
    for IPIP tunnels, when route to endpoint is allowed to change)
  */

+/* Subtype attributes for IFLA_PROTINFO */
+enum
+{
+	IFLA_INET6_UNSPEC,
+	IFLA_INET6_FLAGS,	/* link flags			*/
+	IFLA_INET6_CONF,	/* sysctl parameters		*/
+	IFLA_INET6_STATS,	/* statistics			*/
+	IFLA_INET6_MCAST,	/* MC things. What of them?	*/
+};
+
+#define IFLA_INET6_MAX	IFLA_INET6_MCAST
+
 /*****************************************************************
  *		Traffic control messages.
  ****/
diff -ruN linux-2.6.0-test1.plist/include/net/if_inet6.h linux-2.6.0-test1.new/include/net/if_inet6.h
--- linux-2.6.0-test1.plist/include/net/if_inet6.h	2003-07-13 20:38:43.000000000 -0700
+++ linux-2.6.0-test1.new/include/net/if_inet6.h	2003-07-31 11:25:46.000000000 -0700
@@ -16,7 +16,12 @@
 #define _NET_IF_INET6_H

 #include <net/snmp.h>
+#include <linux/ipv6.h>

+/* inet6_dev.if_flags */
+
+#define IF_RA_OTHERCONF	0x80
+#define IF_RA_MANAGED	0x40
 #define IF_RA_RCVD	0x20
 #define IF_RS_SENT	0x10

@@ -132,28 +137,6 @@
 #define	IFA_SITE	IPV6_ADDR_SITELOCAL
 #define	IFA_GLOBAL	0x0000U

-struct ipv6_devconf
-{
-	int		forwarding;
-	int		hop_limit;
-	int		mtu6;
-	int		accept_ra;
-	int		accept_redirects;
-	int		autoconf;
-	int		dad_transmits;
-	int		rtr_solicits;
-	int		rtr_solicit_interval;
-	int		rtr_solicit_delay;
-#ifdef CONFIG_IPV6_PRIVACY
-	int		use_tempaddr;
-	int		temp_valid_lft;
-	int		temp_prefered_lft;
-	int		regen_max_retry;
-	int		max_desync_factor;
-#endif
-	void		*sysctl;
-};
-
 struct ipv6_devstat {
 	struct proc_dir_entry	*proc_dir_entry;
 	DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6);
diff -ruN linux-2.6.0-test1.plist/net/ipv6/addrconf.c linux-2.6.0-test1.new/net/ipv6/addrconf.c
--- linux-2.6.0-test1.plist/net/ipv6/addrconf.c	2003-07-31 12:00:39.000000000 -0700
+++ linux-2.6.0-test1.new/net/ipv6/addrconf.c	2003-07-31 11:43:54.000000000 -0700
@@ -2510,7 +2510,107 @@
 	netlink_broadcast(rtnl, skb, 0, RTMGRP_IPV6_IFADDR, GFP_ATOMIC);
 }

+static void inline ipv6_store_devconf(struct ipv6_devconf *cnf, __s32 *array)
+{
+	array[DEVCONF_FORWARDING] = cnf->forwarding;
+	array[DEVCONF_HOPLIMIT] = cnf->hop_limit;
+	array[DEVCONF_MTU6] = cnf->mtu6;
+	array[DEVCONF_ACCEPT_RA] = cnf->accept_ra;
+	array[DEVCONF_ACCEPT_REDIRECTS] = cnf->accept_redirects;
+	array[DEVCONF_AUTOCONF] = cnf->autoconf;
+	array[DEVCONF_DAD_TRANSMITS] = cnf->dad_transmits;
+	array[DEVCONF_RTR_SOLICITS] = cnf->rtr_solicits;
+	array[DEVCONF_RTR_SOLICIT_INTERVAL] = cnf->rtr_solicit_interval;
+	array[DEVCONF_RTR_SOLICIT_DELAY] = cnf->rtr_solicit_delay;
+#ifdef CONFIG_IPV6_PRIVACY
+	array[DEVCONF_USE_TEMPADDR] = cnf->use_tempaddr;
+	array[DEVCONF_TEMP_VALID_LFT] = cnf->temp_valid_lft;
+	array[DEVCONF_TEMP_PREFERED_LFT] = cnf->temp_prefered_lft;
+	array[DEVCONF_REGEN_MAX_RETRY] = cnf->regen_max_retry;
+	array[DEVCONF_MAX_DESYNC_FACTOR] = cnf->max_desync_factor;
+#endif
+}
+
+static int inet6_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
+			    struct inet6_dev *idev,
+			    int type, u32 pid, u32 seq)
+{
+	__s32			*array = NULL;
+	struct ifinfomsg	*r;
+	struct nlmsghdr 	*nlh;
+	unsigned char		*b = skb->tail;
+	struct rtattr		*subattr;
+
+	nlh = NLMSG_PUT(skb, pid, seq, type, sizeof(*r));
+	if (pid) nlh->nlmsg_flags |= NLM_F_MULTI;
+	r = NLMSG_DATA(nlh);
+	r->ifi_family = AF_INET6;
+	r->ifi_type = dev->type;
+	r->ifi_index = dev->ifindex;
+	r->ifi_flags = dev->flags;
+	r->ifi_change = 0;
+	if (!netif_running(dev) || !netif_carrier_ok(dev))
+		r->ifi_flags &= ~IFF_RUNNING;
+	else
+		r->ifi_flags |= IFF_RUNNING;
+
+	RTA_PUT(skb, IFLA_IFNAME, strlen(dev->name)+1, dev->name);
+
+	subattr = (struct rtattr*)skb->tail;
+
+	RTA_PUT(skb, IFLA_PROTINFO, 0, NULL);
+
+	/* return the device flags */
+	RTA_PUT(skb, IFLA_INET6_FLAGS, sizeof(__u32), &idev->if_flags);
+
+	/* return the device sysctl params */
+	if ((array = kmalloc(DEVCONF_MAX * sizeof(*array), GFP_KERNEL)) == NULL)
+		goto rtattr_failure;
+	ipv6_store_devconf(&idev->cnf, array);
+	RTA_PUT(skb, IFLA_INET6_CONF, DEVCONF_MAX * sizeof(*array), array);
+
+	/* XXX - Statistics/MC not implemented */
+	subattr->rta_len = skb->tail - (u8*)subattr;
+
+	nlh->nlmsg_len = skb->tail - b;
+	kfree(array);
+	return skb->len;
+
+nlmsg_failure:
+rtattr_failure:
+	if (array)
+		kfree(array);
+	skb_trim(skb, b - skb->data);
+	return -1;
+}
+
+static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
+{
+	int idx, err;
+	int s_idx = cb->args[0];
+	struct net_device *dev;
+	struct inet6_dev *idev;
+
+	read_lock(&dev_base_lock);
+	for (dev=dev_base, idx=0; dev; dev = dev->next, idx++) {
+		if (idx < s_idx)
+			continue;
+		if ((idev = in6_dev_get(dev)) == NULL)
+			continue;
+		err = inet6_fill_ifinfo(skb, dev, idev, RTM_NEWLINK,
+				NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq);
+		in6_dev_put(idev);
+		if (err <= 0)
+			break;
+	}
+	read_unlock(&dev_base_lock);
+	cb->args[0] = idx;
+
+	return skb->len;
+}
+
 static struct rtnetlink_link inet6_rtnetlink_table[RTM_MAX - RTM_BASE + 1] = {
+	[RTM_GETLINK - RTM_BASE] = { .dumpit	= inet6_dump_ifinfo, },
 	[RTM_NEWADDR - RTM_BASE] = { .doit	= inet6_rtm_newaddr, },
 	[RTM_DELADDR - RTM_BASE] = { .doit	= inet6_rtm_deladdr, },
 	[RTM_GETADDR - RTM_BASE] = { .dumpit	= inet6_dump_ifaddr, },
diff -ruN linux-2.6.0-test1.plist/net/ipv6/ndisc.c linux-2.6.0-test1.new/net/ipv6/ndisc.c
--- linux-2.6.0-test1.plist/net/ipv6/ndisc.c	2003-07-13 20:35:12.000000000 -0700
+++ linux-2.6.0-test1.new/net/ipv6/ndisc.c	2003-07-31 11:24:39.000000000 -0700
@@ -1037,6 +1037,17 @@
 		in6_dev->if_flags |= IF_RA_RCVD;
 	}

+	/*
+	 * Remember the managed/otherconf flags from most recently
+	 * received RA message (RFC 2462) -- yoshfuji
+	 */
+	in6_dev->if_flags = (in6_dev->if_flags & ~(IF_RA_MANAGED |
+				IF_RA_OTHERCONF)) |
+				(ra_msg->icmph.icmp6_addrconf_managed ?
+					IF_RA_MANAGED : 0) |
+				(ra_msg->icmph.icmp6_addrconf_other ?
+					IF_RA_OTHERCONF : 0);
+
 	lifetime = ntohs(ra_msg->icmph.icmp6_rt_lifetime);

 	rt = rt6_get_dflt_router(&skb->nh.ipv6h->saddr, skb->dev);

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: O/M flags against 2.6.0-test1
  2003-07-31 20:33                                     ` Krishna Kumar
@ 2003-08-04 23:57                                       ` David S. Miller
  2003-09-05 18:26                                         ` Krishna Kumar
  0 siblings, 1 reply; 52+ messages in thread
From: David S. Miller @ 2003-08-04 23:57 UTC (permalink / raw)
  To: Krishna Kumar; +Cc: kuznet, yoshfuji, netdev, krkumar

On Thu, 31 Jul 2003 13:33:27 -0700 (PDT)
Krishna Kumar <krkumar@us.ibm.com> wrote:

> > Ok, but then please use "__s32".
> 
> OK, slowly getting there :-)
> 
> Latest patch follows :

Krishna is away, but let us make more progress on this patch.
I see some problem with it that still need to be resolved:

> +/* Subtype attributes for IFLA_PROTINFO */
> +enum
> +{
> +	IFLA_INET6_UNSPEC,
> +	IFLA_INET6_FLAGS,	/* link flags			*/
> +	IFLA_INET6_CONF,	/* sysctl parameters		*/
> +	IFLA_INET6_STATS,	/* statistics			*/
> +	IFLA_INET6_MCAST,	/* MC things. What of them?	*/
> +};
> +
> +#define IFLA_INET6_MAX	IFLA_INET6_MCAST

Ok, how does this actually work?  The code does RTA_PUT(...IFLA_INET6_*...)
but IFLA_PROTINFO is not actually used anywhere.  This cannot work, it makes
these RTA attributes just look like whatever IFLA_* ones have the
same values as the inet6 ones in this enumeration.

Alexey, how did you intend this stuff to be done?  Cerainly not
like this :-)

> +	/* return the device sysctl params */
> +	if ((array = kmalloc(DEVCONF_MAX * sizeof(*array), GFP_KERNEL)) == NULL)
> +		goto rtattr_failure;
> +	ipv6_store_devconf(&idev->cnf, array);
> +	RTA_PUT(skb, IFLA_INET6_CONF, DEVCONF_MAX * sizeof(*array), array);

This is what I'm talking about.  Maybe there is something I'm missing.
How does APP know to interpret IFLA_INET6_CONF as "sub-attribute"
of IFLA_PROTINFO?

Also, missing "memset(array, 0, sizeof(*array));" else we leak
uninitialized kernel memory into user space.

Another bug, GFP_KERNEL memory allocation with dev_base_lock held.

Otherwise I am OK with the patch.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: O/M flags against 2.6.0-test1
  2003-08-04 23:57                                       ` David S. Miller
@ 2003-09-05 18:26                                         ` Krishna Kumar
  2003-09-12  2:25                                           ` David S. Miller
  0 siblings, 1 reply; 52+ messages in thread
From: Krishna Kumar @ 2003-09-05 18:26 UTC (permalink / raw)
  To: David S. Miller; +Cc: kuznet, yoshfuji, netdev, Krishna Kumar

Hi Dave,

 > Krishna is away, but let us make more progress on this patch.

I have just got back and I didn't see any follow up on this. I also found
that it is not yet in the 2.6.0-test4 kernel, so would like to find  out what
needs to be done to get it included.

To answer your comments :

 > Ok, how does this actually work?  The code does RTA_PUT(...IFLA_INET6_*...)
 > but IFLA_PROTINFO is not actually used anywhere.  This cannot work, it makes
 > these RTA attributes just look like whatever IFLA_* ones have the
 > same values as the inet6 ones in this enumeration.

The inet6_fill_ifinfo adds a IFLA_PROTINFO msg to the skb and then adds the
sub-attribute like IFLA_INET6_FLAGS, IFLA_INET6_CONF, sets the length of
sub-attr, etc. Code snippet :

	subattr = (struct rtattr*)skb->tail;
	RTA_PUT(skb, IFLA_PROTINFO, 0, NULL);
	/* return the device flags */
	RTA_PUT(skb, IFLA_INET6_FLAGS, sizeof(__u32), &idev->if_flags);

 > > +		 /* return the device sysctl params */
 > > +		 if ((array = kmalloc(DEVCONF_MAX * sizeof(*array), GFP_KERNEL)) == NULL)
 > > +		 		 goto rtattr_failure;
 > > +		 ipv6_store_devconf(&idev->cnf, array);
 > > +		 RTA_PUT(skb, IFLA_INET6_CONF, DEVCONF_MAX * sizeof(*array), array);

 > This is what I'm talking about.  Maybe there is something I'm missing.
 > How does APP know to interpret IFLA_INET6_CONF as "sub-attribute"
 > of IFLA_PROTINFO?

I think this is answered above. Please correct me if I have missed something.

 > Also, missing "memset(array, 0, sizeof(*array));" else we leak
 > uninitialized kernel memory into user space.

Is that needed since the array allocated is exactly DEVCONF_MAX sized and the
ipv6_store_devconf writes exactly DEVCONF_MAX entries and the rta_len is marked
accordinging to finish at the end of the array. But I can still add it for
clarity...

 > Another bug, GFP_KERNEL memory allocation with dev_base_lock held.

Yes, that should be changed to GFP_ATOMIC.

 > Otherwise I am OK with the patch.

OK, should I fix these two bugs and re-submit against test4 kernel ?

Dave, I would like to get the prefix list and O/M flags information included
in 2.4 kernel too, are you OK with that ?

Thanks,

- KK

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: O/M flags against 2.6.0-test1
  2003-09-05 18:26                                         ` Krishna Kumar
@ 2003-09-12  2:25                                           ` David S. Miller
  2003-09-12 22:36                                             ` Krishna Kumar
  2003-09-12 22:45                                             ` O/M flags for 2.4.22 (was "Re: O/M flags against 2.6.0-test1") Krishna Kumar
  0 siblings, 2 replies; 52+ messages in thread
From: David S. Miller @ 2003-09-12  2:25 UTC (permalink / raw)
  To: Krishna Kumar; +Cc: kuznet, yoshfuji, netdev, krkumar

On Fri, 05 Sep 2003 11:26:47 -0700
Krishna Kumar <krkumar@us.ibm.com> wrote:

>  > Otherwise I am OK with the patch.
> 
> OK, should I fix these two bugs and re-submit against test4 kernel ?
> 
> Dave, I would like to get the prefix list and O/M flags information included
> in 2.4 kernel too, are you OK with that ?

Yes, rebuild the patch against current 2.6.x and yes I'm happy
to apply a 2.4.x version as well.

Also, thank you for explaining how the message embedding works.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: O/M flags against 2.6.0-test1
  2003-09-12  2:25                                           ` David S. Miller
@ 2003-09-12 22:36                                             ` Krishna Kumar
  2003-09-12 22:45                                             ` O/M flags for 2.4.22 (was "Re: O/M flags against 2.6.0-test1") Krishna Kumar
  1 sibling, 0 replies; 52+ messages in thread
From: Krishna Kumar @ 2003-09-12 22:36 UTC (permalink / raw)
  To: David S. Miller; +Cc: kuznet, yoshfuji, netdev, KK

> Yes, rebuild the patch against current 2.6.x

Patch against 2.6.0-test5 follows.

Thanks,

- KK

diff -ruN linux-2.6.0-test5.org/include/linux/ipv6.h linux-2.6.0-test5/include/linux/ipv6.h
--- linux-2.6.0-test5.org/include/linux/ipv6.h	2003-09-08 12:50:17.000000000 -0700
+++ linux-2.6.0-test5/include/linux/ipv6.h	2003-09-12 12:33:14.000000000 -0700
@@ -122,6 +122,52 @@
 	struct	in6_addr	daddr;
 };

+/*
+ * This structure contains configuration options per IPv6 link.
+ */
+struct ipv6_devconf {
+	__s32		forwarding;
+	__s32		hop_limit;
+	__s32		mtu6;
+	__s32		accept_ra;
+	__s32		accept_redirects;
+	__s32		autoconf;
+	__s32		dad_transmits;
+	__s32		rtr_solicits;
+	__s32		rtr_solicit_interval;
+	__s32		rtr_solicit_delay;
+#ifdef CONFIG_IPV6_PRIVACY
+	__s32		use_tempaddr;
+	__s32		temp_valid_lft;
+	__s32		temp_prefered_lft;
+	__s32		regen_max_retry;
+	__s32		max_desync_factor;
+#endif
+	void		*sysctl;
+};
+
+/* index values for the variables in ipv6_devconf */
+enum {
+	DEVCONF_FORWARDING = 0,
+	DEVCONF_HOPLIMIT,
+	DEVCONF_MTU6,
+	DEVCONF_ACCEPT_RA,
+	DEVCONF_ACCEPT_REDIRECTS,
+	DEVCONF_AUTOCONF,
+	DEVCONF_DAD_TRANSMITS,
+	DEVCONF_RTR_SOLICITS,
+	DEVCONF_RTR_SOLICIT_INTERVAL,
+	DEVCONF_RTR_SOLICIT_DELAY,
+#ifdef CONFIG_IPV6_PRIVACY
+	DEVCONF_USE_TEMPADDR,
+	DEVCONF_TEMP_VALID_LFT,
+	DEVCONF_TEMP_PREFERED_LFT,
+	DEVCONF_REGEN_MAX_RETRY,
+	DEVCONF_MAX_DESYNC_FACTOR,
+#endif
+	DEVCONF_MAX
+};
+
 #ifdef __KERNEL__
 #include <linux/in6.h>          /* struct sockaddr_in6 */
 #include <linux/icmpv6.h>
diff -ruN linux-2.6.0-test5.org/include/linux/rtnetlink.h linux-2.6.0-test5/include/linux/rtnetlink.h
--- linux-2.6.0-test5.org/include/linux/rtnetlink.h	2003-09-08 12:50:21.000000000 -0700
+++ linux-2.6.0-test5/include/linux/rtnetlink.h	2003-09-12 12:33:14.000000000 -0700
@@ -508,10 +508,12 @@
 #define IFLA_MASTER IFLA_MASTER
 	IFLA_WIRELESS,		/* Wireless Extension event - see wireless.h */
 #define IFLA_WIRELESS IFLA_WIRELESS
+	IFLA_PROTINFO,		/* Protocol specific information for a link */
+#define IFLA_PROTINFO IFLA_PROTINFO
 };


-#define IFLA_MAX IFLA_WIRELESS
+#define IFLA_MAX IFLA_PROTINFO

 #define IFLA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
 #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
@@ -545,6 +547,18 @@
    for IPIP tunnels, when route to endpoint is allowed to change)
  */

+/* Subtype attributes for IFLA_PROTINFO */
+enum
+{
+	IFLA_INET6_UNSPEC,
+	IFLA_INET6_FLAGS,	/* link flags			*/
+	IFLA_INET6_CONF,	/* sysctl parameters		*/
+	IFLA_INET6_STATS,	/* statistics			*/
+	IFLA_INET6_MCAST,	/* MC things. What of them?	*/
+};
+
+#define IFLA_INET6_MAX	IFLA_INET6_MCAST
+
 /*****************************************************************
  *		Traffic control messages.
  ****/
diff -ruN linux-2.6.0-test5.org/include/net/if_inet6.h linux-2.6.0-test5/include/net/if_inet6.h
--- linux-2.6.0-test5.org/include/net/if_inet6.h	2003-09-08 12:50:33.000000000 -0700
+++ linux-2.6.0-test5/include/net/if_inet6.h	2003-09-12 12:33:14.000000000 -0700
@@ -16,7 +16,12 @@
 #define _NET_IF_INET6_H

 #include <net/snmp.h>
+#include <linux/ipv6.h>

+/* inet6_dev.if_flags */
+
+#define IF_RA_OTHERCONF	0x80
+#define IF_RA_MANAGED	0x40
 #define IF_RA_RCVD	0x20
 #define IF_RS_SENT	0x10

@@ -132,28 +137,6 @@
 #define	IFA_SITE	IPV6_ADDR_SITELOCAL
 #define	IFA_GLOBAL	0x0000U

-struct ipv6_devconf
-{
-	int		forwarding;
-	int		hop_limit;
-	int		mtu6;
-	int		accept_ra;
-	int		accept_redirects;
-	int		autoconf;
-	int		dad_transmits;
-	int		rtr_solicits;
-	int		rtr_solicit_interval;
-	int		rtr_solicit_delay;
-#ifdef CONFIG_IPV6_PRIVACY
-	int		use_tempaddr;
-	int		temp_valid_lft;
-	int		temp_prefered_lft;
-	int		regen_max_retry;
-	int		max_desync_factor;
-#endif
-	void		*sysctl;
-};
-
 struct ipv6_devstat {
 	struct proc_dir_entry	*proc_dir_entry;
 	DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6);
diff -ruN linux-2.6.0-test5.org/net/ipv6/addrconf.c linux-2.6.0-test5/net/ipv6/addrconf.c
--- linux-2.6.0-test5.org/net/ipv6/addrconf.c	2003-09-08 12:50:29.000000000 -0700
+++ linux-2.6.0-test5/net/ipv6/addrconf.c	2003-09-12 15:01:10.000000000 -0700
@@ -2529,7 +2529,109 @@
 	netlink_broadcast(rtnl, skb, 0, RTMGRP_IPV6_IFADDR, GFP_ATOMIC);
 }

+static void inline ipv6_store_devconf(struct ipv6_devconf *cnf,
+				__s32 *array, int bytes)
+{
+	memset(array, 0, bytes);
+	array[DEVCONF_FORWARDING] = cnf->forwarding;
+	array[DEVCONF_HOPLIMIT] = cnf->hop_limit;
+	array[DEVCONF_MTU6] = cnf->mtu6;
+	array[DEVCONF_ACCEPT_RA] = cnf->accept_ra;
+	array[DEVCONF_ACCEPT_REDIRECTS] = cnf->accept_redirects;
+	array[DEVCONF_AUTOCONF] = cnf->autoconf;
+	array[DEVCONF_DAD_TRANSMITS] = cnf->dad_transmits;
+	array[DEVCONF_RTR_SOLICITS] = cnf->rtr_solicits;
+	array[DEVCONF_RTR_SOLICIT_INTERVAL] = cnf->rtr_solicit_interval;
+	array[DEVCONF_RTR_SOLICIT_DELAY] = cnf->rtr_solicit_delay;
+#ifdef CONFIG_IPV6_PRIVACY
+	array[DEVCONF_USE_TEMPADDR] = cnf->use_tempaddr;
+	array[DEVCONF_TEMP_VALID_LFT] = cnf->temp_valid_lft;
+	array[DEVCONF_TEMP_PREFERED_LFT] = cnf->temp_prefered_lft;
+	array[DEVCONF_REGEN_MAX_RETRY] = cnf->regen_max_retry;
+	array[DEVCONF_MAX_DESYNC_FACTOR] = cnf->max_desync_factor;
+#endif
+}
+
+static int inet6_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
+			    struct inet6_dev *idev,
+			    int type, u32 pid, u32 seq)
+{
+	__s32			*array = NULL;
+	struct ifinfomsg	*r;
+	struct nlmsghdr 	*nlh;
+	unsigned char		*b = skb->tail;
+	struct rtattr		*subattr;
+
+	nlh = NLMSG_PUT(skb, pid, seq, type, sizeof(*r));
+	if (pid) nlh->nlmsg_flags |= NLM_F_MULTI;
+	r = NLMSG_DATA(nlh);
+	r->ifi_family = AF_INET6;
+	r->ifi_type = dev->type;
+	r->ifi_index = dev->ifindex;
+	r->ifi_flags = dev->flags;
+	r->ifi_change = 0;
+	if (!netif_running(dev) || !netif_carrier_ok(dev))
+		r->ifi_flags &= ~IFF_RUNNING;
+	else
+		r->ifi_flags |= IFF_RUNNING;
+
+	RTA_PUT(skb, IFLA_IFNAME, strlen(dev->name)+1, dev->name);
+
+	subattr = (struct rtattr*)skb->tail;
+
+	RTA_PUT(skb, IFLA_PROTINFO, 0, NULL);
+
+	/* return the device flags */
+	RTA_PUT(skb, IFLA_INET6_FLAGS, sizeof(__u32), &idev->if_flags);
+
+	/* return the device sysctl params */
+	if ((array = kmalloc(DEVCONF_MAX * sizeof(*array), GFP_ATOMIC)) == NULL)
+		goto rtattr_failure;
+	ipv6_store_devconf(&idev->cnf, array, DEVCONF_MAX * sizeof(*array));
+	RTA_PUT(skb, IFLA_INET6_CONF, DEVCONF_MAX * sizeof(*array), array);
+
+	/* XXX - Statistics/MC not implemented */
+	subattr->rta_len = skb->tail - (u8*)subattr;
+
+	nlh->nlmsg_len = skb->tail - b;
+	kfree(array);
+	return skb->len;
+
+nlmsg_failure:
+rtattr_failure:
+	if (array)
+		kfree(array);
+	skb_trim(skb, b - skb->data);
+	return -1;
+}
+
+static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
+{
+	int idx, err;
+	int s_idx = cb->args[0];
+	struct net_device *dev;
+	struct inet6_dev *idev;
+
+	read_lock(&dev_base_lock);
+	for (dev=dev_base, idx=0; dev; dev = dev->next, idx++) {
+		if (idx < s_idx)
+			continue;
+		if ((idev = in6_dev_get(dev)) == NULL)
+			continue;
+		err = inet6_fill_ifinfo(skb, dev, idev, RTM_NEWLINK,
+				NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq);
+		in6_dev_put(idev);
+		if (err <= 0)
+			break;
+	}
+	read_unlock(&dev_base_lock);
+	cb->args[0] = idx;
+
+	return skb->len;
+}
+
 static struct rtnetlink_link inet6_rtnetlink_table[RTM_MAX - RTM_BASE + 1] = {
+	[RTM_GETLINK - RTM_BASE] = { .dumpit	= inet6_dump_ifinfo, },
 	[RTM_NEWADDR - RTM_BASE] = { .doit	= inet6_rtm_newaddr, },
 	[RTM_DELADDR - RTM_BASE] = { .doit	= inet6_rtm_deladdr, },
 	[RTM_GETADDR - RTM_BASE] = { .dumpit	= inet6_dump_ifaddr, },
diff -ruN linux-2.6.0-test5.org/net/ipv6/ndisc.c linux-2.6.0-test5/net/ipv6/ndisc.c
--- linux-2.6.0-test5.org/net/ipv6/ndisc.c	2003-09-08 12:50:07.000000000 -0700
+++ linux-2.6.0-test5/net/ipv6/ndisc.c	2003-09-12 12:33:14.000000000 -0700
@@ -1044,6 +1044,17 @@
 		in6_dev->if_flags |= IF_RA_RCVD;
 	}

+	/*
+	 * Remember the managed/otherconf flags from most recently
+	 * received RA message (RFC 2462) -- yoshfuji
+	 */
+	in6_dev->if_flags = (in6_dev->if_flags & ~(IF_RA_MANAGED |
+				IF_RA_OTHERCONF)) |
+				(ra_msg->icmph.icmp6_addrconf_managed ?
+					IF_RA_MANAGED : 0) |
+				(ra_msg->icmph.icmp6_addrconf_other ?
+					IF_RA_OTHERCONF : 0);
+
 	lifetime = ntohs(ra_msg->icmph.icmp6_rt_lifetime);

 	rt = rt6_get_dflt_router(&skb->nh.ipv6h->saddr, skb->dev);

^ permalink raw reply	[flat|nested] 52+ messages in thread

* O/M flags for 2.4.22 (was "Re: O/M flags against 2.6.0-test1")
  2003-09-12  2:25                                           ` David S. Miller
  2003-09-12 22:36                                             ` Krishna Kumar
@ 2003-09-12 22:45                                             ` Krishna Kumar
  2003-09-13  0:19                                               ` David S. Miller
  1 sibling, 1 reply; 52+ messages in thread
From: Krishna Kumar @ 2003-09-12 22:45 UTC (permalink / raw)
  To: David S. Miller; +Cc: kuznet, yoshfuji, netdev, KK


> I'm happy to apply a 2.4.x version as well.

Patch against 2.4.22 follows.

Thanks,

- KK

diff -ruN linux-2.4.22.org/include/linux/ipv6.h linux-2.4.22/include/linux/ipv6.h
--- linux-2.4.22.org/include/linux/ipv6.h	2001-11-22 11:47:11.000000000 -0800
+++ linux-2.4.22/include/linux/ipv6.h	2003-09-12 15:11:09.000000000 -0700
@@ -100,6 +100,52 @@
 	struct	in6_addr	daddr;
 };

+/*
+ * This structure contains configuration options per IPv6 link.
+ */
+struct ipv6_devconf {
+	__s32		forwarding;
+	__s32		hop_limit;
+	__s32		mtu6;
+	__s32		accept_ra;
+	__s32		accept_redirects;
+	__s32		autoconf;
+	__s32		dad_transmits;
+	__s32		rtr_solicits;
+	__s32		rtr_solicit_interval;
+	__s32		rtr_solicit_delay;
+#ifdef CONFIG_IPV6_PRIVACY
+	__s32		use_tempaddr;
+	__s32		temp_valid_lft;
+	__s32		temp_prefered_lft;
+	__s32		regen_max_retry;
+	__s32		max_desync_factor;
+#endif
+	void		*sysctl;
+};
+
+/* index values for the variables in ipv6_devconf */
+enum {
+	DEVCONF_FORWARDING = 0,
+	DEVCONF_HOPLIMIT,
+	DEVCONF_MTU6,
+	DEVCONF_ACCEPT_RA,
+	DEVCONF_ACCEPT_REDIRECTS,
+	DEVCONF_AUTOCONF,
+	DEVCONF_DAD_TRANSMITS,
+	DEVCONF_RTR_SOLICITS,
+	DEVCONF_RTR_SOLICIT_INTERVAL,
+	DEVCONF_RTR_SOLICIT_DELAY,
+#ifdef CONFIG_IPV6_PRIVACY
+	DEVCONF_USE_TEMPADDR,
+	DEVCONF_TEMP_VALID_LFT,
+	DEVCONF_TEMP_PREFERED_LFT,
+	DEVCONF_REGEN_MAX_RETRY,
+	DEVCONF_MAX_DESYNC_FACTOR,
+#endif
+	DEVCONF_MAX
+};
+
 #ifdef __KERNEL__

 /*
diff -ruN linux-2.4.22.org/include/linux/rtnetlink.h linux-2.4.22/include/linux/rtnetlink.h
--- linux-2.4.22.org/include/linux/rtnetlink.h	2003-08-25 04:44:44.000000000 -0700
+++ linux-2.4.22/include/linux/rtnetlink.h	2003-09-12 13:07:45.000000000 -0700
@@ -444,10 +444,12 @@
 #define IFLA_MASTER IFLA_MASTER
 	IFLA_WIRELESS,		/* Wireless Extension event - see wireless.h */
 #define IFLA_WIRELESS IFLA_WIRELESS
+	IFLA_PROTINFO,		/* Protocol specific information for a link */
+#define IFLA_PROTINFO IFLA_PROTINFO
 };


-#define IFLA_MAX IFLA_WIRELESS
+#define IFLA_MAX IFLA_PROTINFO

 #define IFLA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
 #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
@@ -481,6 +483,18 @@
    for IPIP tunnels, when route to endpoint is allowed to change)
  */

+/* Subtype attributes for IFLA_PROTINFO */
+enum
+{
+	IFLA_INET6_UNSPEC,
+	IFLA_INET6_FLAGS,	/* link flags			*/
+	IFLA_INET6_CONF,	/* sysctl parameters		*/
+	IFLA_INET6_STATS,	/* statistics			*/
+	IFLA_INET6_MCAST,	/* MC things. What of them?	*/
+};
+
+#define IFLA_INET6_MAX	IFLA_INET6_MCAST
+
 /*****************************************************************
  *		Traffic control messages.
  ****/
diff -ruN linux-2.4.22.org/include/net/if_inet6.h linux-2.4.22/include/net/if_inet6.h
--- linux-2.4.22.org/include/net/if_inet6.h	2003-08-25 04:44:44.000000000 -0700
+++ linux-2.4.22/include/net/if_inet6.h	2003-09-12 15:11:09.000000000 -0700
@@ -15,6 +15,10 @@
 #ifndef _NET_IF_INET6_H
 #define _NET_IF_INET6_H

+#include <linux/ipv6.h>
+
+#define IF_RA_OTHERCONF	0x80
+#define IF_RA_MANAGED	0x40
 #define IF_RA_RCVD	0x20
 #define IF_RS_SENT	0x10

@@ -124,22 +128,6 @@
 #define	IFA_SITE	IPV6_ADDR_SITELOCAL
 #define	IFA_GLOBAL	0x0000U

-struct ipv6_devconf
-{
-	int		forwarding;
-	int		hop_limit;
-	int		mtu6;
-	int		accept_ra;
-	int		accept_redirects;
-	int		autoconf;
-	int		dad_transmits;
-	int		rtr_solicits;
-	int		rtr_solicit_interval;
-	int		rtr_solicit_delay;
-
-	void		*sysctl;
-};
-
 struct inet6_dev
 {
 	struct net_device		*dev;
diff -ruN linux-2.4.22.org/net/ipv6/addrconf.c linux-2.4.22/net/ipv6/addrconf.c
--- linux-2.4.22.org/net/ipv6/addrconf.c	2003-08-25 04:44:44.000000000 -0700
+++ linux-2.4.22/net/ipv6/addrconf.c	2003-09-12 15:01:00.000000000 -0700
@@ -1981,11 +1981,112 @@
 	netlink_broadcast(rtnl, skb, 0, RTMGRP_IPV6_IFADDR, GFP_ATOMIC);
 }

+static void inline ipv6_store_devconf(struct ipv6_devconf *cnf,
+				__s32 *array, int bytes)
+{
+	memset(array, 0, bytes);
+	array[DEVCONF_FORWARDING] = cnf->forwarding;
+	array[DEVCONF_HOPLIMIT] = cnf->hop_limit;
+	array[DEVCONF_MTU6] = cnf->mtu6;
+	array[DEVCONF_ACCEPT_RA] = cnf->accept_ra;
+	array[DEVCONF_ACCEPT_REDIRECTS] = cnf->accept_redirects;
+	array[DEVCONF_AUTOCONF] = cnf->autoconf;
+	array[DEVCONF_DAD_TRANSMITS] = cnf->dad_transmits;
+	array[DEVCONF_RTR_SOLICITS] = cnf->rtr_solicits;
+	array[DEVCONF_RTR_SOLICIT_INTERVAL] = cnf->rtr_solicit_interval;
+	array[DEVCONF_RTR_SOLICIT_DELAY] = cnf->rtr_solicit_delay;
+#ifdef CONFIG_IPV6_PRIVACY
+	array[DEVCONF_USE_TEMPADDR] = cnf->use_tempaddr;
+	array[DEVCONF_TEMP_VALID_LFT] = cnf->temp_valid_lft;
+	array[DEVCONF_TEMP_PREFERED_LFT] = cnf->temp_prefered_lft;
+	array[DEVCONF_REGEN_MAX_RETRY] = cnf->regen_max_retry;
+	array[DEVCONF_MAX_DESYNC_FACTOR] = cnf->max_desync_factor;
+#endif
+}
+
+static int inet6_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
+			    struct inet6_dev *idev,
+			    int type, u32 pid, u32 seq)
+{
+	__s32			*array = NULL;
+	struct ifinfomsg	*r;
+	struct nlmsghdr 	*nlh;
+	unsigned char		*b = skb->tail;
+	struct rtattr		*subattr;
+
+	nlh = NLMSG_PUT(skb, pid, seq, type, sizeof(*r));
+	if (pid) nlh->nlmsg_flags |= NLM_F_MULTI;
+	r = NLMSG_DATA(nlh);
+	r->ifi_family = AF_INET6;
+	r->ifi_type = dev->type;
+	r->ifi_index = dev->ifindex;
+	r->ifi_flags = dev->flags;
+	r->ifi_change = 0;
+	if (!netif_running(dev) || !netif_carrier_ok(dev))
+		r->ifi_flags &= ~IFF_RUNNING;
+	else
+		r->ifi_flags |= IFF_RUNNING;
+
+	RTA_PUT(skb, IFLA_IFNAME, strlen(dev->name)+1, dev->name);
+
+	subattr = (struct rtattr*)skb->tail;
+
+	RTA_PUT(skb, IFLA_PROTINFO, 0, NULL);
+
+	/* return the device flags */
+	RTA_PUT(skb, IFLA_INET6_FLAGS, sizeof(__u32), &idev->if_flags);
+
+	/* return the device sysctl params */
+	if ((array = kmalloc(DEVCONF_MAX * sizeof(*array), GFP_ATOMIC)) == NULL)
+		goto rtattr_failure;
+	ipv6_store_devconf(&idev->cnf, array, DEVCONF_MAX * sizeof(*array));
+	RTA_PUT(skb, IFLA_INET6_CONF, DEVCONF_MAX * sizeof(*array), array);
+
+	/* XXX - Statistics/MC not implemented */
+	subattr->rta_len = skb->tail - (u8*)subattr;
+
+	nlh->nlmsg_len = skb->tail - b;
+	kfree(array);
+	return skb->len;
+
+nlmsg_failure:
+rtattr_failure:
+	if (array)
+		kfree(array);
+	skb_trim(skb, b - skb->data);
+	return -1;
+}
+
+static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
+{
+	int idx, err;
+	int s_idx = cb->args[0];
+	struct net_device *dev;
+	struct inet6_dev *idev;
+
+	read_lock(&dev_base_lock);
+	for (dev=dev_base, idx=0; dev; dev = dev->next, idx++) {
+		if (idx < s_idx)
+			continue;
+		if ((idev = in6_dev_get(dev)) == NULL)
+			continue;
+		err = inet6_fill_ifinfo(skb, dev, idev, RTM_NEWLINK,
+				NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq);
+		in6_dev_put(idev);
+		if (err <= 0)
+			break;
+	}
+	read_unlock(&dev_base_lock);
+	cb->args[0] = idx;
+
+	return skb->len;
+}
+
 static struct rtnetlink_link inet6_rtnetlink_table[RTM_MAX-RTM_BASE+1] =
 {
 	{ NULL,			NULL,			},
 	{ NULL,			NULL,			},
-	{ NULL,			NULL,			},
+	{ NULL,			inet6_dump_ifinfo,	},
 	{ NULL,			NULL,			},

 	{ inet6_rtm_newaddr,	NULL,			},
diff -ruN linux-2.4.22.org/net/ipv6/ndisc.c linux-2.4.22/net/ipv6/ndisc.c
--- linux-2.4.22.org/net/ipv6/ndisc.c	2003-08-25 04:44:44.000000000 -0700
+++ linux-2.4.22/net/ipv6/ndisc.c	2003-09-12 13:07:45.000000000 -0700
@@ -944,6 +944,17 @@
 		in6_dev->if_flags |= IF_RA_RCVD;
 	}

+	/*
+	 * Remember the managed/otherconf flags from most recently
+	 * received RA message (RFC 2462) -- yoshfuji
+	 */
+	in6_dev->if_flags = (in6_dev->if_flags & ~(IF_RA_MANAGED |
+				IF_RA_OTHERCONF)) |
+				(ra_msg->icmph.icmp6_addrconf_managed ?
+					IF_RA_MANAGED : 0) |
+				(ra_msg->icmph.icmp6_addrconf_other ?
+					IF_RA_OTHERCONF : 0);
+
 	lifetime = ntohs(ra_msg->icmph.icmp6_rt_lifetime);

 	rt = rt6_get_dflt_router(&skb->nh.ipv6h->saddr, skb->dev);

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: O/M flags for 2.4.22 (was "Re: O/M flags against 2.6.0-test1")
  2003-09-12 22:45                                             ` O/M flags for 2.4.22 (was "Re: O/M flags against 2.6.0-test1") Krishna Kumar
@ 2003-09-13  0:19                                               ` David S. Miller
  2003-09-16 22:06                                                 ` Krishna Kumar
  0 siblings, 1 reply; 52+ messages in thread
From: David S. Miller @ 2003-09-13  0:19 UTC (permalink / raw)
  To: Krishna Kumar; +Cc: kuznet, yoshfuji, netdev, krkumar

On Fri, 12 Sep 2003 15:45:15 -0700 (PDT)
Krishna Kumar <krkumar@us.ibm.com> wrote:

> > I'm happy to apply a 2.4.x version as well.
> 
> Patch against 2.4.22 follows.

I applied the 2.6.x version, but this 2.4.x version does
not apply cleanly, there are a bunch of rejects.

That's not surprising since there's been, as there always is, several
networking updates in 2.4.x since 2.4.22 already which cause conflicts
with your patch.

Please always, and I mean always, create patches against the most
recent possible version of 2.4.x or 2.6.x.  We'll never have
to go back and forth like this if you do that.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: O/M flags for 2.4.22 (was "Re: O/M flags against 2.6.0-test1")
  2003-09-13  0:19                                               ` David S. Miller
@ 2003-09-16 22:06                                                 ` Krishna Kumar
  2003-09-20  8:18                                                   ` David S. Miller
  0 siblings, 1 reply; 52+ messages in thread
From: Krishna Kumar @ 2003-09-16 22:06 UTC (permalink / raw)
  To: David S. Miller; +Cc: kuznet, yoshfuji, netdev, KK

> I applied the 2.6.x version, but this 2.4.x version does
> not apply cleanly, there are a bunch of rejects.

Sorry about that, will remember to use the latest version.

The patch is against 2.4.22-bk19.

Thanks,

- KK

diff -ruN linux-2.4.22.org/include/linux/ipv6.h linux-2.4.22/include/linux/ipv6.h
--- linux-2.4.22.org/include/linux/ipv6.h	2003-09-16 14:32:11.000000000 -0700
+++ linux-2.4.22/include/linux/ipv6.h	2003-09-16 14:33:10.000000000 -0700
@@ -100,6 +100,52 @@
 	struct	in6_addr	daddr;
 };

+/*
+ * This structure contains configuration options per IPv6 link.
+ */
+struct ipv6_devconf {
+	__s32		forwarding;
+	__s32		hop_limit;
+	__s32		mtu6;
+	__s32		accept_ra;
+	__s32		accept_redirects;
+	__s32		autoconf;
+	__s32		dad_transmits;
+	__s32		rtr_solicits;
+	__s32		rtr_solicit_interval;
+	__s32		rtr_solicit_delay;
+#ifdef CONFIG_IPV6_PRIVACY
+	__s32		use_tempaddr;
+	__s32		temp_valid_lft;
+	__s32		temp_prefered_lft;
+	__s32		regen_max_retry;
+	__s32		max_desync_factor;
+#endif
+	void		*sysctl;
+};
+
+/* index values for the variables in ipv6_devconf */
+enum {
+	DEVCONF_FORWARDING = 0,
+	DEVCONF_HOPLIMIT,
+	DEVCONF_MTU6,
+	DEVCONF_ACCEPT_RA,
+	DEVCONF_ACCEPT_REDIRECTS,
+	DEVCONF_AUTOCONF,
+	DEVCONF_DAD_TRANSMITS,
+	DEVCONF_RTR_SOLICITS,
+	DEVCONF_RTR_SOLICIT_INTERVAL,
+	DEVCONF_RTR_SOLICIT_DELAY,
+#ifdef CONFIG_IPV6_PRIVACY
+	DEVCONF_USE_TEMPADDR,
+	DEVCONF_TEMP_VALID_LFT,
+	DEVCONF_TEMP_PREFERED_LFT,
+	DEVCONF_REGEN_MAX_RETRY,
+	DEVCONF_MAX_DESYNC_FACTOR,
+#endif
+	DEVCONF_MAX
+};
+
 #ifdef __KERNEL__

 /*
diff -ruN linux-2.4.22.org/include/linux/rtnetlink.h linux-2.4.22/include/linux/rtnetlink.h
--- linux-2.4.22.org/include/linux/rtnetlink.h	2003-09-16 14:32:11.000000000 -0700
+++ linux-2.4.22/include/linux/rtnetlink.h	2003-09-16 14:33:10.000000000 -0700
@@ -445,10 +445,12 @@
 #define IFLA_MASTER IFLA_MASTER
 	IFLA_WIRELESS,		/* Wireless Extension event - see wireless.h */
 #define IFLA_WIRELESS IFLA_WIRELESS
+	IFLA_PROTINFO,		/* Protocol specific information for a link */
+#define IFLA_PROTINFO IFLA_PROTINFO
 };


-#define IFLA_MAX IFLA_WIRELESS
+#define IFLA_MAX IFLA_PROTINFO

 #define IFLA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
 #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
@@ -482,6 +484,18 @@
    for IPIP tunnels, when route to endpoint is allowed to change)
  */

+/* Subtype attributes for IFLA_PROTINFO */
+enum
+{
+	IFLA_INET6_UNSPEC,
+	IFLA_INET6_FLAGS,	/* link flags			*/
+	IFLA_INET6_CONF,	/* sysctl parameters		*/
+	IFLA_INET6_STATS,	/* statistics			*/
+	IFLA_INET6_MCAST,	/* MC things. What of them?	*/
+};
+
+#define IFLA_INET6_MAX	IFLA_INET6_MCAST
+
 /*****************************************************************
  *		Traffic control messages.
  ****/
diff -ruN linux-2.4.22.org/include/net/if_inet6.h linux-2.4.22/include/net/if_inet6.h
--- linux-2.4.22.org/include/net/if_inet6.h	2003-08-25 04:44:44.000000000 -0700
+++ linux-2.4.22/include/net/if_inet6.h	2003-09-16 14:33:10.000000000 -0700
@@ -15,6 +15,10 @@
 #ifndef _NET_IF_INET6_H
 #define _NET_IF_INET6_H

+#include <linux/ipv6.h>
+
+#define IF_RA_OTHERCONF	0x80
+#define IF_RA_MANAGED	0x40
 #define IF_RA_RCVD	0x20
 #define IF_RS_SENT	0x10

@@ -124,22 +128,6 @@
 #define	IFA_SITE	IPV6_ADDR_SITELOCAL
 #define	IFA_GLOBAL	0x0000U

-struct ipv6_devconf
-{
-	int		forwarding;
-	int		hop_limit;
-	int		mtu6;
-	int		accept_ra;
-	int		accept_redirects;
-	int		autoconf;
-	int		dad_transmits;
-	int		rtr_solicits;
-	int		rtr_solicit_interval;
-	int		rtr_solicit_delay;
-
-	void		*sysctl;
-};
-
 struct inet6_dev
 {
 	struct net_device		*dev;
diff -ruN linux-2.4.22.org/net/ipv6/addrconf.c linux-2.4.22/net/ipv6/addrconf.c
--- linux-2.4.22.org/net/ipv6/addrconf.c	2003-09-16 14:32:13.000000000 -0700
+++ linux-2.4.22/net/ipv6/addrconf.c	2003-09-16 14:33:10.000000000 -0700
@@ -1981,11 +1981,112 @@
 	netlink_broadcast(rtnl, skb, 0, RTMGRP_IPV6_IFADDR, GFP_ATOMIC);
 }

+static void inline ipv6_store_devconf(struct ipv6_devconf *cnf,
+				__s32 *array, int bytes)
+{
+	memset(array, 0, bytes);
+	array[DEVCONF_FORWARDING] = cnf->forwarding;
+	array[DEVCONF_HOPLIMIT] = cnf->hop_limit;
+	array[DEVCONF_MTU6] = cnf->mtu6;
+	array[DEVCONF_ACCEPT_RA] = cnf->accept_ra;
+	array[DEVCONF_ACCEPT_REDIRECTS] = cnf->accept_redirects;
+	array[DEVCONF_AUTOCONF] = cnf->autoconf;
+	array[DEVCONF_DAD_TRANSMITS] = cnf->dad_transmits;
+	array[DEVCONF_RTR_SOLICITS] = cnf->rtr_solicits;
+	array[DEVCONF_RTR_SOLICIT_INTERVAL] = cnf->rtr_solicit_interval;
+	array[DEVCONF_RTR_SOLICIT_DELAY] = cnf->rtr_solicit_delay;
+#ifdef CONFIG_IPV6_PRIVACY
+	array[DEVCONF_USE_TEMPADDR] = cnf->use_tempaddr;
+	array[DEVCONF_TEMP_VALID_LFT] = cnf->temp_valid_lft;
+	array[DEVCONF_TEMP_PREFERED_LFT] = cnf->temp_prefered_lft;
+	array[DEVCONF_REGEN_MAX_RETRY] = cnf->regen_max_retry;
+	array[DEVCONF_MAX_DESYNC_FACTOR] = cnf->max_desync_factor;
+#endif
+}
+
+static int inet6_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
+			    struct inet6_dev *idev,
+			    int type, u32 pid, u32 seq)
+{
+	__s32			*array = NULL;
+	struct ifinfomsg	*r;
+	struct nlmsghdr 	*nlh;
+	unsigned char		*b = skb->tail;
+	struct rtattr		*subattr;
+
+	nlh = NLMSG_PUT(skb, pid, seq, type, sizeof(*r));
+	if (pid) nlh->nlmsg_flags |= NLM_F_MULTI;
+	r = NLMSG_DATA(nlh);
+	r->ifi_family = AF_INET6;
+	r->ifi_type = dev->type;
+	r->ifi_index = dev->ifindex;
+	r->ifi_flags = dev->flags;
+	r->ifi_change = 0;
+	if (!netif_running(dev) || !netif_carrier_ok(dev))
+		r->ifi_flags &= ~IFF_RUNNING;
+	else
+		r->ifi_flags |= IFF_RUNNING;
+
+	RTA_PUT(skb, IFLA_IFNAME, strlen(dev->name)+1, dev->name);
+
+	subattr = (struct rtattr*)skb->tail;
+
+	RTA_PUT(skb, IFLA_PROTINFO, 0, NULL);
+
+	/* return the device flags */
+	RTA_PUT(skb, IFLA_INET6_FLAGS, sizeof(__u32), &idev->if_flags);
+
+	/* return the device sysctl params */
+	if ((array = kmalloc(DEVCONF_MAX * sizeof(*array), GFP_ATOMIC)) == NULL)
+		goto rtattr_failure;
+	ipv6_store_devconf(&idev->cnf, array, DEVCONF_MAX * sizeof(*array));
+	RTA_PUT(skb, IFLA_INET6_CONF, DEVCONF_MAX * sizeof(*array), array);
+
+	/* XXX - Statistics/MC not implemented */
+	subattr->rta_len = skb->tail - (u8*)subattr;
+
+	nlh->nlmsg_len = skb->tail - b;
+	kfree(array);
+	return skb->len;
+
+nlmsg_failure:
+rtattr_failure:
+	if (array)
+		kfree(array);
+	skb_trim(skb, b - skb->data);
+	return -1;
+}
+
+static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
+{
+	int idx, err;
+	int s_idx = cb->args[0];
+	struct net_device *dev;
+	struct inet6_dev *idev;
+
+	read_lock(&dev_base_lock);
+	for (dev=dev_base, idx=0; dev; dev = dev->next, idx++) {
+		if (idx < s_idx)
+			continue;
+		if ((idev = in6_dev_get(dev)) == NULL)
+			continue;
+		err = inet6_fill_ifinfo(skb, dev, idev, RTM_NEWLINK,
+				NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq);
+		in6_dev_put(idev);
+		if (err <= 0)
+			break;
+	}
+	read_unlock(&dev_base_lock);
+	cb->args[0] = idx;
+
+	return skb->len;
+}
+
 static struct rtnetlink_link inet6_rtnetlink_table[RTM_MAX-RTM_BASE+1] =
 {
 	{ NULL,			NULL,			},
 	{ NULL,			NULL,			},
-	{ NULL,			NULL,			},
+	{ NULL,			inet6_dump_ifinfo,	},
 	{ NULL,			NULL,			},

 	{ inet6_rtm_newaddr,	NULL,			},
diff -ruN linux-2.4.22.org/net/ipv6/ndisc.c linux-2.4.22/net/ipv6/ndisc.c
--- linux-2.4.22.org/net/ipv6/ndisc.c	2003-09-16 14:32:13.000000000 -0700
+++ linux-2.4.22/net/ipv6/ndisc.c	2003-09-16 14:33:10.000000000 -0700
@@ -944,6 +944,17 @@
 		in6_dev->if_flags |= IF_RA_RCVD;
 	}

+	/*
+	 * Remember the managed/otherconf flags from most recently
+	 * received RA message (RFC 2462) -- yoshfuji
+	 */
+	in6_dev->if_flags = (in6_dev->if_flags & ~(IF_RA_MANAGED |
+				IF_RA_OTHERCONF)) |
+				(ra_msg->icmph.icmp6_addrconf_managed ?
+					IF_RA_MANAGED : 0) |
+				(ra_msg->icmph.icmp6_addrconf_other ?
+					IF_RA_OTHERCONF : 0);
+
 	lifetime = ntohs(ra_msg->icmph.icmp6_rt_lifetime);

 	rt = rt6_get_dflt_router(&skb->nh.ipv6h->saddr, skb->dev);

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: O/M flags for 2.4.22 (was "Re: O/M flags against 2.6.0-test1")
  2003-09-16 22:06                                                 ` Krishna Kumar
@ 2003-09-20  8:18                                                   ` David S. Miller
  0 siblings, 0 replies; 52+ messages in thread
From: David S. Miller @ 2003-09-20  8:18 UTC (permalink / raw)
  To: Krishna Kumar; +Cc: kuznet, yoshfuji, netdev, krkumar

On Tue, 16 Sep 2003 15:06:37 -0700 (PDT)
Krishna Kumar <krkumar@us.ibm.com> wrote:

> The patch is against 2.4.22-bk19.

Applied, thanks Krishna.

^ permalink raw reply	[flat|nested] 52+ messages in thread

end of thread, other threads:[~2003-09-20  8:18 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-14 22:35 [PATCH 1/4] Prefix List against 2.5.73 Krishna Kumar
2003-07-15  1:17 ` kuznet
2003-07-15  6:59   ` YOSHIFUJI Hideaki / 吉藤英明
2003-07-15 13:20     ` kuznet
2003-07-15 18:34   ` Krishna Kumar
2003-07-16  0:11     ` Krishna Kumar
2003-07-16  0:21     ` kuznet
2003-07-16  8:39       ` YOSHIFUJI Hideaki / 吉藤英明
2003-07-16 18:42         ` [PATCH 1/2] " Krishna Kumar
2003-07-16 18:49           ` Krishna Kumar
2003-07-16 18:50           ` [PATCH 2/2] Prefix List against 2.4.21 Krishna Kumar
2003-07-16 23:41         ` [PATCH 1/4] Prefix List against 2.5.73 kuznet
2003-07-17  0:06           ` Krishna Kumar
2003-07-17  0:38             ` kuznet
2003-07-17 21:12               ` [PATCH 1/2] Prefix List and O/M flags " Krishna Kumar
2003-07-17 22:06                 ` [PATCH 2/2] Prefix List and O/M flags against 2.4.21 Krishna Kumar
2003-07-17 22:22                   ` YOSHIFUJI Hideaki / 吉藤英明
2003-07-17 22:34                     ` Krishna Kumar
2003-07-17 22:47                       ` YOSHIFUJI Hideaki / 吉藤英明
2003-07-18  0:37                         ` [PATCH 2/2] Prefix List and O/M flags against 2.5.73 Krishna Kumar
2003-07-19  6:47                           ` David S. Miller
2003-07-19  7:33                           ` YOSHIFUJI Hideaki / 吉藤英明
2003-07-21  0:49                             ` kuznet
2003-07-21 12:17                           ` David S. Miller
2003-07-21 17:16                             ` Krishna Kumar
2003-07-21  1:55                       ` [PATCH 2/2] Prefix List and O/M flags against 2.4.21 kuznet
2003-07-21  4:46                         ` David S. Miller
2003-07-22 21:50                         ` O/M flags against 2.6.0-test1 Krishna Kumar
2003-07-22 22:25                           ` YOSHIFUJI Hideaki / 吉藤英明
2003-07-22 22:59                             ` Krishna Kumar
2003-07-23 10:13                           ` David S. Miller
2003-07-23 22:32                             ` Krishna Kumar
2003-07-24  7:07                               ` David S. Miller
2003-07-24 14:02                                 ` kuznet
2003-07-24 14:26                                   ` YOSHIFUJI Hideaki / 吉藤英明
2003-07-24 14:43                                     ` kuznet
2003-07-25  0:14                                       ` Krishna Kumar
2003-07-25 13:22                                         ` David S. Miller
2003-07-30  0:33                                 ` Krishna Kumar
2003-07-31  5:02                                   ` David S. Miller
2003-07-31 20:33                                     ` Krishna Kumar
2003-08-04 23:57                                       ` David S. Miller
2003-09-05 18:26                                         ` Krishna Kumar
2003-09-12  2:25                                           ` David S. Miller
2003-09-12 22:36                                             ` Krishna Kumar
2003-09-12 22:45                                             ` O/M flags for 2.4.22 (was "Re: O/M flags against 2.6.0-test1") Krishna Kumar
2003-09-13  0:19                                               ` David S. Miller
2003-09-16 22:06                                                 ` Krishna Kumar
2003-09-20  8:18                                                   ` David S. Miller
2003-07-22 23:52                         ` [PATCH] Prefix List against 2.4.21 Krishna Kumar
2003-07-23 10:02                           ` David S. Miller
2003-07-17 21:53               ` [PATCH 1/4] Prefix List against 2.5.73 YOSHIFUJI Hideaki / 吉藤英明

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.