public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Pavel Emelyanov <xemul@parallels•com>
To: David Miller <davem@davemloft•net>,
	Linux Netdev List <netdev@vger•kernel.org>
Subject: [PATCH 6/11] inet_diag: Introduce new inet_diag_req header
Date: Tue, 06 Dec 2011 21:58:21 +0400	[thread overview]
Message-ID: <4EDE57BD.1020207@parallels.com> (raw)
In-Reply-To: <4EDE573A.6040607@parallels.com>

This one coinsides with the sock_diag_req in the beginning and 
contains only used fields from its previous analogue.

The existing code is patched to use the _compat version of it
for now.

Signed-off-by: Pavel Emelyanov <xemul@parallels•com>

---
 include/linux/inet_diag.h |   11 ++++++++++-
 net/ipv4/inet_diag.c      |   14 +++++++-------
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/include/linux/inet_diag.h b/include/linux/inet_diag.h
index f7baaf6..defe8ff 100644
--- a/include/linux/inet_diag.h
+++ b/include/linux/inet_diag.h
@@ -23,7 +23,7 @@ struct inet_diag_sockid {
 
 /* Request structure */
 
-struct inet_diag_req {
+struct inet_diag_req_compat {
 	__u8	idiag_family;		/* Family of addresses. */
 	__u8	idiag_src_len;
 	__u8	idiag_dst_len;
@@ -35,6 +35,15 @@ struct inet_diag_req {
 	__u32	idiag_dbs;		/* Tables to dump (NI) */
 };
 
+struct inet_diag_req {
+	__u8	sdiag_family;
+	__u8	sdiag_protocol;
+	__u8	idiag_ext;
+	__u8	pad;
+	__u32	idiag_states;
+	struct inet_diag_sockid id;
+};
+
 enum {
 	INET_DIAG_REQ_NONE,
 	INET_DIAG_REQ_BYTECODE,
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index ccbe8ea..9a6a6de 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -265,7 +265,7 @@ static int inet_diag_get_exact(struct sk_buff *in_skb,
 {
 	int err;
 	struct sock *sk;
-	struct inet_diag_req *req = NLMSG_DATA(nlh);
+	struct inet_diag_req_compat *req = NLMSG_DATA(nlh);
 	struct sk_buff *rep;
 	struct inet_hashinfo *hashinfo;
 	const struct inet_diag_handler *handler;
@@ -504,7 +504,7 @@ static int inet_csk_diag_dump(struct sock *sk,
 			      struct netlink_callback *cb,
 			      const struct nlattr *bc)
 {
-	struct inet_diag_req *r = NLMSG_DATA(cb->nlh);
+	struct inet_diag_req_compat *r = NLMSG_DATA(cb->nlh);
 
 	if (bc != NULL) {
 		struct inet_diag_entry entry;
@@ -541,7 +541,7 @@ static int inet_twsk_diag_dump(struct inet_timewait_sock *tw,
 			       struct netlink_callback *cb,
 			       const struct nlattr *bc)
 {
-	struct inet_diag_req *r = NLMSG_DATA(cb->nlh);
+	struct inet_diag_req_compat *r = NLMSG_DATA(cb->nlh);
 
 	if (bc != NULL) {
 		struct inet_diag_entry entry;
@@ -629,7 +629,7 @@ static int inet_diag_dump_reqs(struct sk_buff *skb, struct sock *sk,
 			       const struct nlattr *bc)
 {
 	struct inet_diag_entry entry;
-	struct inet_diag_req *r = NLMSG_DATA(cb->nlh);
+	struct inet_diag_req_compat *r = NLMSG_DATA(cb->nlh);
 	struct inet_connection_sock *icsk = inet_csk(sk);
 	struct listen_sock *lopt;
 	struct inet_sock *inet = inet_sk(sk);
@@ -712,12 +712,12 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	int i, num;
 	int s_i, s_num;
-	struct inet_diag_req *r = NLMSG_DATA(cb->nlh);
+	struct inet_diag_req_compat *r = NLMSG_DATA(cb->nlh);
 	const struct inet_diag_handler *handler;
 	struct inet_hashinfo *hashinfo;
 	const struct nlattr *bc = NULL;
 
-	if (nlmsg_attrlen(cb->nlh, sizeof(struct inet_diag_req)))
+	if (nlmsg_attrlen(cb->nlh, sizeof(struct inet_diag_req_compat)))
 		bc = nlmsg_find_attr(cb->nlh, sizeof(*r), INET_DIAG_REQ_BYTECODE);
 
 	handler = inet_diag_lock_handler(inet_diag_type2proto(cb->nlh->nlmsg_type));
@@ -863,7 +863,7 @@ unlock:
 
 static int inet_diag_rcv_msg_compat(struct sk_buff *skb, struct nlmsghdr *nlh)
 {
-	int hdrlen = sizeof(struct inet_diag_req);
+	int hdrlen = sizeof(struct inet_diag_req_compat);
 
 	if (nlh->nlmsg_type >= INET_DIAG_GETSOCK_MAX ||
 	    nlmsg_len(nlh) < hdrlen)
-- 
1.5.5.6

  parent reply	other threads:[~2011-12-06 17:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-06 17:56 [PATCH 0/11] Generalize the inet_diag infrastructure Pavel Emelyanov
2011-12-06 17:56 ` [PATCH 1/11] inet_diag: Partly rename inet_ to sock_ Pavel Emelyanov
2011-12-06 18:24   ` Stephen Hemminger
2011-12-06 18:42     ` David Miller
2011-12-06 17:57 ` [PATCH 2/11] sock_diag: Introduce new message type Pavel Emelyanov
2011-12-06 17:57 ` [PATCH 3/11] inet_diag: Move byte-code finding up the call-stack Pavel Emelyanov
2011-12-06 17:58 ` [PATCH 5/11] sock_diag: Initial skeleton Pavel Emelyanov
2011-12-06 17:58 ` Pavel Emelyanov [this message]
2011-12-06 17:58 ` [PATCH 7/11] inet_diag: Switch the _get_exact to work with new header Pavel Emelyanov
2011-12-06 17:58 ` [PATCH 8/11] inet_diag: Switch the _dump " Pavel Emelyanov
2011-12-06 17:59 ` [PATCH 9/11] inet_diag: Introduce socket family checks Pavel Emelyanov
2011-12-06 17:59 ` [PATCH 10/11] inet_diag: Cleanup type2proto last user Pavel Emelyanov
2011-12-06 17:59 ` [PATCH 11/11] sock_diag: Move the sock_ code to net/core/ Pavel Emelyanov
2011-12-06 18:02 ` [PATCH] iproute: Use SOCK_DIAG_BY_FAMILY messages Pavel Emelyanov
2012-01-20 21:05   ` Stephen Hemminger
     [not found] ` <4EDE5797.6010603@parallels.com>
2011-12-06 18:05   ` [PATCH 4/11] inet_diag: Switch from _GETSOCK to IPPROTO_ numbers Pavel Emelyanov
2011-12-06 18:58 ` [PATCH 0/11] Generalize the inet_diag infrastructure David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EDE57BD.1020207@parallels.com \
    --to=xemul@parallels$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox