Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 289828
b: refs/heads/master
c: a46621a
h: refs/heads/master
v: v3
  • Loading branch information
Denys Vlasenko authored and David S. Miller committed Jan 30, 2012
1 parent 80bd205 commit d6b93b5
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 81 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5de658f878d49e952d7b3f3f26a396132829f513
refs/heads/master: a46621a3a8f24557201a7ef62de151c812f8985c
18 changes: 2 additions & 16 deletions trunk/include/linux/netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,22 +237,8 @@ struct netlink_notify {
int protocol;
};

static __inline__ struct nlmsghdr *
__nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags)
{
struct nlmsghdr *nlh;
int size = NLMSG_LENGTH(len);

nlh = (struct nlmsghdr*)skb_put(skb, NLMSG_ALIGN(size));
nlh->nlmsg_type = type;
nlh->nlmsg_len = size;
nlh->nlmsg_flags = flags;
nlh->nlmsg_pid = pid;
nlh->nlmsg_seq = seq;
if (!__builtin_constant_p(size) || NLMSG_ALIGN(size) - size != 0)
memset(NLMSG_DATA(nlh) + len, 0, NLMSG_ALIGN(size) - size);
return nlh;
}
struct nlmsghdr *
__nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags);

#define NLMSG_NEW(skb, pid, seq, type, len, flags) \
({ if (unlikely(skb_tailroom(skb) < (int)NLMSG_SPACE(len))) \
Expand Down
31 changes: 2 additions & 29 deletions trunk/include/net/genetlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,35 +131,8 @@ extern void genl_unregister_mc_group(struct genl_family *family,
extern void genl_notify(struct sk_buff *skb, struct net *net, u32 pid,
u32 group, struct nlmsghdr *nlh, gfp_t flags);

/**
* genlmsg_put - Add generic netlink header to netlink message
* @skb: socket buffer holding the message
* @pid: netlink pid the message is addressed to
* @seq: sequence number (usually the one of the sender)
* @family: generic netlink family
* @flags netlink message flags
* @cmd: generic netlink command
*
* Returns pointer to user specific header
*/
static inline void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq,
struct genl_family *family, int flags, u8 cmd)
{
struct nlmsghdr *nlh;
struct genlmsghdr *hdr;

nlh = nlmsg_put(skb, pid, seq, family->id, GENL_HDRLEN +
family->hdrsize, flags);
if (nlh == NULL)
return NULL;

hdr = nlmsg_data(nlh);
hdr->cmd = cmd;
hdr->version = family->version;
hdr->reserved = 0;

return (char *) hdr + GENL_HDRLEN;
}
void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq,
struct genl_family *family, int flags, u8 cmd);

/**
* genlmsg_nlhdr - Obtain netlink header from user specified header
Expand Down
35 changes: 0 additions & 35 deletions trunk/include/net/netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,41 +441,6 @@ static inline int nlmsg_report(const struct nlmsghdr *nlh)
nla_for_each_attr(pos, nlmsg_attrdata(nlh, hdrlen), \
nlmsg_attrlen(nlh, hdrlen), rem)

#if 0
/* FIXME: Enable once all users have been converted */

/**
* __nlmsg_put - Add a new netlink message to an skb
* @skb: socket buffer to store message in
* @pid: netlink process id
* @seq: sequence number of message
* @type: message type
* @payload: length of message payload
* @flags: message flags
*
* The caller is responsible to ensure that the skb provides enough
* tailroom for both the netlink header and payload.
*/
static inline struct nlmsghdr *__nlmsg_put(struct sk_buff *skb, u32 pid,
u32 seq, int type, int payload,
int flags)
{
struct nlmsghdr *nlh;

nlh = (struct nlmsghdr *) skb_put(skb, nlmsg_total_size(payload));
nlh->nlmsg_type = type;
nlh->nlmsg_len = nlmsg_msg_size(payload);
nlh->nlmsg_flags = flags;
nlh->nlmsg_pid = pid;
nlh->nlmsg_seq = seq;

memset((unsigned char *) nlmsg_data(nlh) + payload, 0,
nlmsg_padlen(payload));

return nlh;
}
#endif

/**
* nlmsg_put - Add a new netlink message to an skb
* @skb: socket buffer to store message in
Expand Down
18 changes: 18 additions & 0 deletions trunk/net/netlink/af_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1645,6 +1645,24 @@ static void netlink_destroy_callback(struct netlink_callback *cb)
kfree(cb);
}

struct nlmsghdr *
__nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags)
{
struct nlmsghdr *nlh;
int size = NLMSG_LENGTH(len);

nlh = (struct nlmsghdr*)skb_put(skb, NLMSG_ALIGN(size));
nlh->nlmsg_type = type;
nlh->nlmsg_len = size;
nlh->nlmsg_flags = flags;
nlh->nlmsg_pid = pid;
nlh->nlmsg_seq = seq;
if (!__builtin_constant_p(size) || NLMSG_ALIGN(size) - size != 0)
memset(NLMSG_DATA(nlh) + len, 0, NLMSG_ALIGN(size) - size);
return nlh;
}
EXPORT_SYMBOL(__nlmsg_put);

/*
* It looks a bit ugly.
* It would be better to create kernel thread.
Expand Down
31 changes: 31 additions & 0 deletions trunk/net/netlink/genetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,37 @@ int genl_unregister_family(struct genl_family *family)
}
EXPORT_SYMBOL(genl_unregister_family);

/**
* genlmsg_put - Add generic netlink header to netlink message
* @skb: socket buffer holding the message
* @pid: netlink pid the message is addressed to
* @seq: sequence number (usually the one of the sender)
* @family: generic netlink family
* @flags netlink message flags
* @cmd: generic netlink command
*
* Returns pointer to user specific header
*/
void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq,
struct genl_family *family, int flags, u8 cmd)
{
struct nlmsghdr *nlh;
struct genlmsghdr *hdr;

nlh = nlmsg_put(skb, pid, seq, family->id, GENL_HDRLEN +
family->hdrsize, flags);
if (nlh == NULL)
return NULL;

hdr = nlmsg_data(nlh);
hdr->cmd = cmd;
hdr->version = family->version;
hdr->reserved = 0;

return (char *) hdr + GENL_HDRLEN;
}
EXPORT_SYMBOL(genlmsg_put);

static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
{
struct genl_ops *ops;
Expand Down

0 comments on commit d6b93b5

Please sign in to comment.