netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net-netlink: Add a new attribute to expose TOS values via netlink
@ 2011-10-10 18:54 Muraliraja Muniraju
  2011-10-10 20:07 ` Stephen Hemminger
  0 siblings, 1 reply; 5+ messages in thread
From: Muraliraja Muniraju @ 2011-10-10 18:54 UTC (permalink / raw)
  To: David S. Miller", Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy <ka
  Cc: linux-kernel, netdev, Murali Raja

From: Murali Raja <muralira@google.com>

This patch exposes the tos value for the TCP sockets when the TOS flag
is requested in the ext_flags for the inet_diag request. This would mainly be
used to expose TOS values for both for TCP and UDP sockets. Currently it is
supported for TCP. When netlink support for UDP would be added the support
to expose the TOS values would alse be done.

Signed-off-by: Murali Raja <muralira@google.com>
---
 include/linux/inet_diag.h |   10 +++++++++-
 net/ipv4/inet_diag.c      |    7 +++++++
 2 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/include/linux/inet_diag.h b/include/linux/inet_diag.h
index bc8c490..f590a59 100644
--- a/include/linux/inet_diag.h
+++ b/include/linux/inet_diag.h
@@ -97,9 +97,10 @@ enum {
 	INET_DIAG_INFO,
 	INET_DIAG_VEGASINFO,
 	INET_DIAG_CONG,
+	INET_DIAG_TOS,
 };
 
-#define INET_DIAG_MAX INET_DIAG_CONG
+#define INET_DIAG_MAX INET_DIAG_TOS
 
 
 /* INET_DIAG_MEM */
@@ -120,6 +121,13 @@ struct tcpvegas_info {
 	__u32	tcpv_minrtt;
 };
 
+/* INET_DIAG_TOS */
+
+struct inet_diag_tos {
+	__u8	idiag_tos;
+	__u8	idiag_reserved[3];
+};
+
 #ifdef __KERNEL__
 struct sock;
 struct inet_hashinfo;
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 389a2e6..6c52e29 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -82,6 +82,7 @@ static int inet_csk_diag_fill(struct sock *sk,
 	struct nlmsghdr  *nlh;
 	void *info = NULL;
 	struct inet_diag_meminfo  *minfo = NULL;
+	struct inet_diag_tos *tos = NULL;
 	unsigned char	 *b = skb_tail_pointer(skb);
 	const struct inet_diag_handler *handler;
 
@@ -108,6 +109,9 @@ static int inet_csk_diag_fill(struct sock *sk,
 		       icsk->icsk_ca_ops->name);
 	}
 
+	if (ext & (1 << (INET_DIAG_TOS - 1)))
+		tos = INET_DIAG_PUT(skb, INET_DIAG_TOS, sizeof(*tos));
+
 	r->idiag_family = sk->sk_family;
 	r->idiag_state = sk->sk_state;
 	r->idiag_timer = 0;
@@ -169,6 +173,9 @@ static int inet_csk_diag_fill(struct sock *sk,
 	    icsk->icsk_ca_ops && icsk->icsk_ca_ops->get_info)
 		icsk->icsk_ca_ops->get_info(sk, ext, skb);
 
+	if (tos)
+		tos->idiag_tos = inet->tos;
+
 	nlh->nlmsg_len = skb_tail_pointer(skb) - b;
 	return skb->len;
 
-- 
1.7.3.1

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

* Re: [PATCH] net-netlink: Add a new attribute to expose TOS values via netlink
  2011-10-10 18:54 [PATCH] net-netlink: Add a new attribute to expose TOS values via netlink Muraliraja Muniraju
@ 2011-10-10 20:07 ` Stephen Hemminger
  2011-10-10 20:32   ` [PATCH v2] " Muraliraja Muniraju
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2011-10-10 20:07 UTC (permalink / raw)
  To: Muraliraja Muniraju
  Cc: David S. Miller", Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy, linux-kernel, netdev

On Mon, 10 Oct 2011 11:54:26 -0700
Muraliraja Muniraju <muralira@google.com> wrote:

>  
> +/* INET_DIAG_TOS */
> +
> +struct inet_diag_tos {
> +	__u8	idiag_tos;
> +	__u8	idiag_reserved[3];
> +};

No reserved bytes in netlink messages please.

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

* [PATCH v2] net-netlink: Add a new attribute to expose TOS values via netlink
  2011-10-10 20:07 ` Stephen Hemminger
@ 2011-10-10 20:32   ` Muraliraja Muniraju
  2011-10-10 21:09     ` Stephen Hemminger
  0 siblings, 1 reply; 5+ messages in thread
From: Muraliraja Muniraju @ 2011-10-10 20:32 UTC (permalink / raw)
  To: David S. Miller", Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy <ka
  Cc: linux-kernel, netdev, Murali Raja

From: Murali Raja <muralira@google.com>

This patch exposes the tos value for the TCP sockets when the TOS flag
is requested in the ext_flags for the inet_diag request. This would mainly be
used to expose TOS values for both for TCP and UDP sockets. Currently it is
supported for TCP. When netlink support for UDP would be added the support
to expose the TOS values would alse be done.

Signed-off-by: Murali Raja <muralira@google.com>
---
Changelog since v1:
- Removing the reserved field.

 include/linux/inet_diag.h |    9 ++++++++-
 net/ipv4/inet_diag.c      |    7 +++++++
 2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/include/linux/inet_diag.h b/include/linux/inet_diag.h
index bc8c490..e36093d 100644
--- a/include/linux/inet_diag.h
+++ b/include/linux/inet_diag.h
@@ -97,9 +97,10 @@ enum {
 	INET_DIAG_INFO,
 	INET_DIAG_VEGASINFO,
 	INET_DIAG_CONG,
+	INET_DIAG_TOS,
 };
 
-#define INET_DIAG_MAX INET_DIAG_CONG
+#define INET_DIAG_MAX INET_DIAG_TOS
 
 
 /* INET_DIAG_MEM */
@@ -120,6 +121,12 @@ struct tcpvegas_info {
 	__u32	tcpv_minrtt;
 };
 
+/* INET_DIAG_TOS */
+
+struct inet_diag_tos {
+	__u8	idiag_tos;
+};
+
 #ifdef __KERNEL__
 struct sock;
 struct inet_hashinfo;
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 389a2e6..6c52e29 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -82,6 +82,7 @@ static int inet_csk_diag_fill(struct sock *sk,
 	struct nlmsghdr  *nlh;
 	void *info = NULL;
 	struct inet_diag_meminfo  *minfo = NULL;
+	struct inet_diag_tos *tos = NULL;
 	unsigned char	 *b = skb_tail_pointer(skb);
 	const struct inet_diag_handler *handler;
 
@@ -108,6 +109,9 @@ static int inet_csk_diag_fill(struct sock *sk,
 		       icsk->icsk_ca_ops->name);
 	}
 
+	if (ext & (1 << (INET_DIAG_TOS - 1)))
+		tos = INET_DIAG_PUT(skb, INET_DIAG_TOS, sizeof(*tos));
+
 	r->idiag_family = sk->sk_family;
 	r->idiag_state = sk->sk_state;
 	r->idiag_timer = 0;
@@ -169,6 +173,9 @@ static int inet_csk_diag_fill(struct sock *sk,
 	    icsk->icsk_ca_ops && icsk->icsk_ca_ops->get_info)
 		icsk->icsk_ca_ops->get_info(sk, ext, skb);
 
+	if (tos)
+		tos->idiag_tos = inet->tos;
+
 	nlh->nlmsg_len = skb_tail_pointer(skb) - b;
 	return skb->len;
 
-- 
1.7.3.1

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

* Re: [PATCH v2] net-netlink: Add a new attribute to expose TOS values via netlink
  2011-10-10 20:32   ` [PATCH v2] " Muraliraja Muniraju
@ 2011-10-10 21:09     ` Stephen Hemminger
  2011-10-10 21:29       ` MuraliRaja Muniraju
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2011-10-10 21:09 UTC (permalink / raw)
  To: Muraliraja Muniraju
  Cc: David S. Miller", Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy, linux-kernel, netdev

On Mon, 10 Oct 2011 13:32:25 -0700
Muraliraja Muniraju <muralira@google.com> wrote:

> From: Murali Raja <muralira@google.com>
> 
> This patch exposes the tos value for the TCP sockets when the TOS flag
> is requested in the ext_flags for the inet_diag request. This would mainly be
> used to expose TOS values for both for TCP and UDP sockets. Currently it is
> supported for TCP. When netlink support for UDP would be added the support
> to expose the TOS values would alse be done.
> 
> Signed-off-by: Murali Raja <muralira@google.com>
> ---
> Changelog since v1:
> - Removing the reserved field.
> 
>  include/linux/inet_diag.h |    9 ++++++++-
>  net/ipv4/inet_diag.c      |    7 +++++++
>  2 files changed, 15 insertions(+), 1 deletions(-)
> 
> diff --git a/include/linux/inet_diag.h b/include/linux/inet_diag.h
> index bc8c490..e36093d 100644
> --- a/include/linux/inet_diag.h
> +++ b/include/linux/inet_diag.h
> @@ -97,9 +97,10 @@ enum {
>  	INET_DIAG_INFO,
>  	INET_DIAG_VEGASINFO,
>  	INET_DIAG_CONG,
> +	INET_DIAG_TOS,
>  };
>  
> -#define INET_DIAG_MAX INET_DIAG_CONG
> +#define INET_DIAG_MAX INET_DIAG_TOS
>  
>  
>  /* INET_DIAG_MEM */
> @@ -120,6 +121,12 @@ struct tcpvegas_info {
>  	__u32	tcpv_minrtt;
>  };
>  
> +/* INET_DIAG_TOS */
> +
> +struct inet_diag_tos {
> +	__u8	idiag_tos;
> +};

I think the idea is a good one, and useful, but want to make the
ABI right.
With only one entry, this doesn't need to be wrapped in a structure.

Also does this work for IPv6 (Transport class) as well?

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

* Re: [PATCH v2] net-netlink: Add a new attribute to expose TOS values via netlink
  2011-10-10 21:09     ` Stephen Hemminger
@ 2011-10-10 21:29       ` MuraliRaja Muniraju
  0 siblings, 0 replies; 5+ messages in thread
From: MuraliRaja Muniraju @ 2011-10-10 21:29 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: David S. Miller", Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy, linux-kernel, netdev

Stephen,
            Regarding the only field in the structure.

            -- I thought that adding it as a attribute and exposing it
via a extension instead of modifying the inet_diag_sockid structure.
This is to make sure that older binaries will not have issues with the
later kernel. Do you have any alternate suggestions.

            This change has been done keeping IPV4 in mind. I do not
see the V6 sockets exposed thought netlink. Please correct me if I am
reading it wrong.

Thanks,
Murali

On Mon, Oct 10, 2011 at 2:09 PM, Stephen Hemminger
<shemminger@vyatta.com> wrote:
> On Mon, 10 Oct 2011 13:32:25 -0700
> Muraliraja Muniraju <muralira@google.com> wrote:
>
>> From: Murali Raja <muralira@google.com>
>>
>> This patch exposes the tos value for the TCP sockets when the TOS flag
>> is requested in the ext_flags for the inet_diag request. This would mainly be
>> used to expose TOS values for both for TCP and UDP sockets. Currently it is
>> supported for TCP. When netlink support for UDP would be added the support
>> to expose the TOS values would alse be done.
>>
>> Signed-off-by: Murali Raja <muralira@google.com>
>> ---
>> Changelog since v1:
>> - Removing the reserved field.
>>
>>  include/linux/inet_diag.h |    9 ++++++++-
>>  net/ipv4/inet_diag.c      |    7 +++++++
>>  2 files changed, 15 insertions(+), 1 deletions(-)
>>
>> diff --git a/include/linux/inet_diag.h b/include/linux/inet_diag.h
>> index bc8c490..e36093d 100644
>> --- a/include/linux/inet_diag.h
>> +++ b/include/linux/inet_diag.h
>> @@ -97,9 +97,10 @@ enum {
>>       INET_DIAG_INFO,
>>       INET_DIAG_VEGASINFO,
>>       INET_DIAG_CONG,
>> +     INET_DIAG_TOS,
>>  };
>>
>> -#define INET_DIAG_MAX INET_DIAG_CONG
>> +#define INET_DIAG_MAX INET_DIAG_TOS
>>
>>
>>  /* INET_DIAG_MEM */
>> @@ -120,6 +121,12 @@ struct tcpvegas_info {
>>       __u32   tcpv_minrtt;
>>  };
>>
>> +/* INET_DIAG_TOS */
>> +
>> +struct inet_diag_tos {
>> +     __u8    idiag_tos;
>> +};
>
> I think the idea is a good one, and useful, but want to make the
> ABI right.
> With only one entry, this doesn't need to be wrapped in a structure.
>
> Also does this work for IPv6 (Transport class) as well?
>
>



-- 
Thanks,
Murali

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

end of thread, other threads:[~2011-10-10 21:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-10 18:54 [PATCH] net-netlink: Add a new attribute to expose TOS values via netlink Muraliraja Muniraju
2011-10-10 20:07 ` Stephen Hemminger
2011-10-10 20:32   ` [PATCH v2] " Muraliraja Muniraju
2011-10-10 21:09     ` Stephen Hemminger
2011-10-10 21:29       ` MuraliRaja Muniraju

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).