Skip to content

Commit

Permalink
inet_diag: Introduce new inet_diag_req header
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
xemul authored and davem330 committed Dec 6, 2011
1 parent d366477 commit 126fdc3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
11 changes: 10 additions & 1 deletion include/linux/inet_diag.h
Expand Up @@ -23,7 +23,7 @@ struct inet_diag_sockid {


/* Request structure */ /* Request structure */


struct inet_diag_req { struct inet_diag_req_compat {
__u8 idiag_family; /* Family of addresses. */ __u8 idiag_family; /* Family of addresses. */
__u8 idiag_src_len; __u8 idiag_src_len;
__u8 idiag_dst_len; __u8 idiag_dst_len;
Expand All @@ -35,6 +35,15 @@ struct inet_diag_req {
__u32 idiag_dbs; /* Tables to dump (NI) */ __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 { enum {
INET_DIAG_REQ_NONE, INET_DIAG_REQ_NONE,
INET_DIAG_REQ_BYTECODE, INET_DIAG_REQ_BYTECODE,
Expand Down
14 changes: 7 additions & 7 deletions net/ipv4/inet_diag.c
Expand Up @@ -265,7 +265,7 @@ static int inet_diag_get_exact(struct sk_buff *in_skb,
{ {
int err; int err;
struct sock *sk; 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 sk_buff *rep;
struct inet_hashinfo *hashinfo; struct inet_hashinfo *hashinfo;
const struct inet_diag_handler *handler; const struct inet_diag_handler *handler;
Expand Down Expand Up @@ -504,7 +504,7 @@ static int inet_csk_diag_dump(struct sock *sk,
struct netlink_callback *cb, struct netlink_callback *cb,
const struct nlattr *bc) 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) { if (bc != NULL) {
struct inet_diag_entry entry; struct inet_diag_entry entry;
Expand Down Expand Up @@ -541,7 +541,7 @@ static int inet_twsk_diag_dump(struct inet_timewait_sock *tw,
struct netlink_callback *cb, struct netlink_callback *cb,
const struct nlattr *bc) 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) { if (bc != NULL) {
struct inet_diag_entry entry; struct inet_diag_entry entry;
Expand Down Expand Up @@ -629,7 +629,7 @@ static int inet_diag_dump_reqs(struct sk_buff *skb, struct sock *sk,
const struct nlattr *bc) const struct nlattr *bc)
{ {
struct inet_diag_entry entry; 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 inet_connection_sock *icsk = inet_csk(sk);
struct listen_sock *lopt; struct listen_sock *lopt;
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
Expand Down Expand Up @@ -712,12 +712,12 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
{ {
int i, num; int i, num;
int s_i, s_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; const struct inet_diag_handler *handler;
struct inet_hashinfo *hashinfo; struct inet_hashinfo *hashinfo;
const struct nlattr *bc = NULL; 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); bc = nlmsg_find_attr(cb->nlh, sizeof(*r), INET_DIAG_REQ_BYTECODE);


handler = inet_diag_lock_handler(inet_diag_type2proto(cb->nlh->nlmsg_type)); handler = inet_diag_lock_handler(inet_diag_type2proto(cb->nlh->nlmsg_type));
Expand Down Expand Up @@ -863,7 +863,7 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)


static int inet_diag_rcv_msg_compat(struct sk_buff *skb, struct nlmsghdr *nlh) 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 || if (nlh->nlmsg_type >= INET_DIAG_GETSOCK_MAX ||
nlmsg_len(nlh) < hdrlen) nlmsg_len(nlh) < hdrlen)
Expand Down

0 comments on commit 126fdc3

Please sign in to comment.