Commit 7b67c857 authored by Thomas Graf's avatar Thomas Graf Committed by David S. Miller

[XFRM] netlink: Use nlmsg_data() instead of NLMSG_DATA()

Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9825069d
...@@ -443,7 +443,7 @@ static struct xfrm_state *xfrm_state_construct(struct xfrm_usersa_info *p, ...@@ -443,7 +443,7 @@ static struct xfrm_state *xfrm_state_construct(struct xfrm_usersa_info *p,
static int xfrm_add_sa(struct sk_buff *skb, struct nlmsghdr *nlh, static int xfrm_add_sa(struct sk_buff *skb, struct nlmsghdr *nlh,
struct rtattr **xfrma) struct rtattr **xfrma)
{ {
struct xfrm_usersa_info *p = NLMSG_DATA(nlh); struct xfrm_usersa_info *p = nlmsg_data(nlh);
struct xfrm_state *x; struct xfrm_state *x;
int err; int err;
struct km_event c; struct km_event c;
...@@ -520,7 +520,7 @@ static int xfrm_del_sa(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -520,7 +520,7 @@ static int xfrm_del_sa(struct sk_buff *skb, struct nlmsghdr *nlh,
struct xfrm_state *x; struct xfrm_state *x;
int err = -ESRCH; int err = -ESRCH;
struct km_event c; struct km_event c;
struct xfrm_usersa_id *p = NLMSG_DATA(nlh); struct xfrm_usersa_id *p = nlmsg_data(nlh);
x = xfrm_user_state_lookup(p, xfrma, &err); x = xfrm_user_state_lookup(p, xfrma, &err);
if (x == NULL) if (x == NULL)
...@@ -592,7 +592,7 @@ static int dump_one_state(struct xfrm_state *x, int count, void *ptr) ...@@ -592,7 +592,7 @@ static int dump_one_state(struct xfrm_state *x, int count, void *ptr)
if (nlh == NULL) if (nlh == NULL)
return -EMSGSIZE; return -EMSGSIZE;
p = NLMSG_DATA(nlh); p = nlmsg_data(nlh);
copy_to_user_state(x, p); copy_to_user_state(x, p);
if (x->aalg) if (x->aalg)
...@@ -715,7 +715,7 @@ static int xfrm_get_spdinfo(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -715,7 +715,7 @@ static int xfrm_get_spdinfo(struct sk_buff *skb, struct nlmsghdr *nlh,
struct rtattr **xfrma) struct rtattr **xfrma)
{ {
struct sk_buff *r_skb; struct sk_buff *r_skb;
u32 *flags = NLMSG_DATA(nlh); u32 *flags = nlmsg_data(nlh);
u32 spid = NETLINK_CB(skb).pid; u32 spid = NETLINK_CB(skb).pid;
u32 seq = nlh->nlmsg_seq; u32 seq = nlh->nlmsg_seq;
int len = NLMSG_LENGTH(sizeof(u32)); int len = NLMSG_LENGTH(sizeof(u32));
...@@ -765,7 +765,7 @@ static int xfrm_get_sadinfo(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -765,7 +765,7 @@ static int xfrm_get_sadinfo(struct sk_buff *skb, struct nlmsghdr *nlh,
struct rtattr **xfrma) struct rtattr **xfrma)
{ {
struct sk_buff *r_skb; struct sk_buff *r_skb;
u32 *flags = NLMSG_DATA(nlh); u32 *flags = nlmsg_data(nlh);
u32 spid = NETLINK_CB(skb).pid; u32 spid = NETLINK_CB(skb).pid;
u32 seq = nlh->nlmsg_seq; u32 seq = nlh->nlmsg_seq;
int len = NLMSG_LENGTH(sizeof(u32)); int len = NLMSG_LENGTH(sizeof(u32));
...@@ -787,7 +787,7 @@ static int xfrm_get_sadinfo(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -787,7 +787,7 @@ static int xfrm_get_sadinfo(struct sk_buff *skb, struct nlmsghdr *nlh,
static int xfrm_get_sa(struct sk_buff *skb, struct nlmsghdr *nlh, static int xfrm_get_sa(struct sk_buff *skb, struct nlmsghdr *nlh,
struct rtattr **xfrma) struct rtattr **xfrma)
{ {
struct xfrm_usersa_id *p = NLMSG_DATA(nlh); struct xfrm_usersa_id *p = nlmsg_data(nlh);
struct xfrm_state *x; struct xfrm_state *x;
struct sk_buff *resp_skb; struct sk_buff *resp_skb;
int err = -ESRCH; int err = -ESRCH;
...@@ -841,7 +841,7 @@ static int xfrm_alloc_userspi(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -841,7 +841,7 @@ static int xfrm_alloc_userspi(struct sk_buff *skb, struct nlmsghdr *nlh,
int family; int family;
int err; int err;
p = NLMSG_DATA(nlh); p = nlmsg_data(nlh);
err = verify_userspi_info(p); err = verify_userspi_info(p);
if (err) if (err)
goto out_noput; goto out_noput;
...@@ -1130,7 +1130,7 @@ static struct xfrm_policy *xfrm_policy_construct(struct xfrm_userpolicy_info *p, ...@@ -1130,7 +1130,7 @@ static struct xfrm_policy *xfrm_policy_construct(struct xfrm_userpolicy_info *p,
static int xfrm_add_policy(struct sk_buff *skb, struct nlmsghdr *nlh, static int xfrm_add_policy(struct sk_buff *skb, struct nlmsghdr *nlh,
struct rtattr **xfrma) struct rtattr **xfrma)
{ {
struct xfrm_userpolicy_info *p = NLMSG_DATA(nlh); struct xfrm_userpolicy_info *p = nlmsg_data(nlh);
struct xfrm_policy *xp; struct xfrm_policy *xp;
struct km_event c; struct km_event c;
int err; int err;
...@@ -1277,8 +1277,8 @@ static int dump_one_policy(struct xfrm_policy *xp, int dir, int count, void *ptr ...@@ -1277,8 +1277,8 @@ static int dump_one_policy(struct xfrm_policy *xp, int dir, int count, void *ptr
XFRM_MSG_NEWPOLICY, sizeof(*p), sp->nlmsg_flags); XFRM_MSG_NEWPOLICY, sizeof(*p), sp->nlmsg_flags);
if (nlh == NULL) if (nlh == NULL)
return -EMSGSIZE; return -EMSGSIZE;
p = NLMSG_DATA(nlh);
p = nlmsg_data(nlh);
copy_to_user_policy(xp, p, dir); copy_to_user_policy(xp, p, dir);
if (copy_to_user_tmpl(xp, skb) < 0) if (copy_to_user_tmpl(xp, skb) < 0)
goto nlmsg_failure; goto nlmsg_failure;
...@@ -1351,7 +1351,7 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -1351,7 +1351,7 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh,
struct km_event c; struct km_event c;
int delete; int delete;
p = NLMSG_DATA(nlh); p = nlmsg_data(nlh);
delete = nlh->nlmsg_type == XFRM_MSG_DELPOLICY; delete = nlh->nlmsg_type == XFRM_MSG_DELPOLICY;
err = copy_from_user_policy_type(&type, xfrma); err = copy_from_user_policy_type(&type, xfrma);
...@@ -1420,7 +1420,7 @@ static int xfrm_flush_sa(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -1420,7 +1420,7 @@ static int xfrm_flush_sa(struct sk_buff *skb, struct nlmsghdr *nlh,
struct rtattr **xfrma) struct rtattr **xfrma)
{ {
struct km_event c; struct km_event c;
struct xfrm_usersa_flush *p = NLMSG_DATA(nlh); struct xfrm_usersa_flush *p = nlmsg_data(nlh);
struct xfrm_audit audit_info; struct xfrm_audit audit_info;
int err; int err;
...@@ -1448,8 +1448,8 @@ static int build_aevent(struct sk_buff *skb, struct xfrm_state *x, struct km_eve ...@@ -1448,8 +1448,8 @@ static int build_aevent(struct sk_buff *skb, struct xfrm_state *x, struct km_eve
nlh = nlmsg_put(skb, c->pid, c->seq, XFRM_MSG_NEWAE, sizeof(*id), 0); nlh = nlmsg_put(skb, c->pid, c->seq, XFRM_MSG_NEWAE, sizeof(*id), 0);
if (nlh == NULL) if (nlh == NULL)
return -EMSGSIZE; return -EMSGSIZE;
id = NLMSG_DATA(nlh);
id = nlmsg_data(nlh);
memcpy(&id->sa_id.daddr, &x->id.daddr,sizeof(x->id.daddr)); memcpy(&id->sa_id.daddr, &x->id.daddr,sizeof(x->id.daddr));
id->sa_id.spi = x->id.spi; id->sa_id.spi = x->id.spi;
id->sa_id.family = x->props.family; id->sa_id.family = x->props.family;
...@@ -1490,7 +1490,7 @@ static int xfrm_get_ae(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -1490,7 +1490,7 @@ static int xfrm_get_ae(struct sk_buff *skb, struct nlmsghdr *nlh,
struct sk_buff *r_skb; struct sk_buff *r_skb;
int err; int err;
struct km_event c; struct km_event c;
struct xfrm_aevent_id *p = NLMSG_DATA(nlh); struct xfrm_aevent_id *p = nlmsg_data(nlh);
int len = NLMSG_LENGTH(sizeof(struct xfrm_aevent_id)); int len = NLMSG_LENGTH(sizeof(struct xfrm_aevent_id));
struct xfrm_usersa_id *id = &p->sa_id; struct xfrm_usersa_id *id = &p->sa_id;
...@@ -1538,7 +1538,7 @@ static int xfrm_new_ae(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -1538,7 +1538,7 @@ static int xfrm_new_ae(struct sk_buff *skb, struct nlmsghdr *nlh,
struct xfrm_state *x; struct xfrm_state *x;
struct km_event c; struct km_event c;
int err = - EINVAL; int err = - EINVAL;
struct xfrm_aevent_id *p = NLMSG_DATA(nlh); struct xfrm_aevent_id *p = nlmsg_data(nlh);
struct rtattr *rp = xfrma[XFRMA_REPLAY_VAL-1]; struct rtattr *rp = xfrma[XFRMA_REPLAY_VAL-1];
struct rtattr *lt = xfrma[XFRMA_LTIME_VAL-1]; struct rtattr *lt = xfrma[XFRMA_LTIME_VAL-1];
...@@ -1602,7 +1602,7 @@ static int xfrm_add_pol_expire(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -1602,7 +1602,7 @@ static int xfrm_add_pol_expire(struct sk_buff *skb, struct nlmsghdr *nlh,
struct rtattr **xfrma) struct rtattr **xfrma)
{ {
struct xfrm_policy *xp; struct xfrm_policy *xp;
struct xfrm_user_polexpire *up = NLMSG_DATA(nlh); struct xfrm_user_polexpire *up = nlmsg_data(nlh);
struct xfrm_userpolicy_info *p = &up->pol; struct xfrm_userpolicy_info *p = &up->pol;
u8 type = XFRM_POLICY_TYPE_MAIN; u8 type = XFRM_POLICY_TYPE_MAIN;
int err = -ENOENT; int err = -ENOENT;
...@@ -1664,7 +1664,7 @@ static int xfrm_add_sa_expire(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -1664,7 +1664,7 @@ static int xfrm_add_sa_expire(struct sk_buff *skb, struct nlmsghdr *nlh,
{ {
struct xfrm_state *x; struct xfrm_state *x;
int err; int err;
struct xfrm_user_expire *ue = NLMSG_DATA(nlh); struct xfrm_user_expire *ue = nlmsg_data(nlh);
struct xfrm_usersa_info *p = &ue->state; struct xfrm_usersa_info *p = &ue->state;
x = xfrm_state_lookup(&p->id.daddr, p->id.spi, p->id.proto, p->family); x = xfrm_state_lookup(&p->id.daddr, p->id.spi, p->id.proto, p->family);
...@@ -1699,7 +1699,7 @@ static int xfrm_add_acquire(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -1699,7 +1699,7 @@ static int xfrm_add_acquire(struct sk_buff *skb, struct nlmsghdr *nlh,
int i; int i;
struct rtattr *rt = xfrma[XFRMA_TMPL-1]; struct rtattr *rt = xfrma[XFRMA_TMPL-1];
struct xfrm_user_acquire *ua = NLMSG_DATA(nlh); struct xfrm_user_acquire *ua = nlmsg_data(nlh);
struct xfrm_state *x = xfrm_state_alloc(); struct xfrm_state *x = xfrm_state_alloc();
int err = -ENOMEM; int err = -ENOMEM;
...@@ -1794,7 +1794,7 @@ static int copy_from_user_migrate(struct xfrm_migrate *ma, ...@@ -1794,7 +1794,7 @@ static int copy_from_user_migrate(struct xfrm_migrate *ma,
static int xfrm_do_migrate(struct sk_buff *skb, struct nlmsghdr *nlh, static int xfrm_do_migrate(struct sk_buff *skb, struct nlmsghdr *nlh,
struct rtattr **xfrma) struct rtattr **xfrma)
{ {
struct xfrm_userpolicy_id *pi = NLMSG_DATA(nlh); struct xfrm_userpolicy_id *pi = nlmsg_data(nlh);
struct xfrm_migrate m[XFRM_MAX_DEPTH]; struct xfrm_migrate m[XFRM_MAX_DEPTH];
u8 type; u8 type;
int err; int err;
...@@ -1863,8 +1863,8 @@ static int build_migrate(struct sk_buff *skb, struct xfrm_migrate *m, ...@@ -1863,8 +1863,8 @@ static int build_migrate(struct sk_buff *skb, struct xfrm_migrate *m,
nlh = nlmsg_put(skb, 0, 0, XFRM_MSG_MIGRATE, sizeof(*pol_id), 0); nlh = nlmsg_put(skb, 0, 0, XFRM_MSG_MIGRATE, sizeof(*pol_id), 0);
if (nlh == NULL) if (nlh == NULL)
return -EMSGSIZE; return -EMSGSIZE;
pol_id = NLMSG_DATA(nlh);
pol_id = nlmsg_data(nlh);
/* copy data from selector, dir, and type to the pol_id */ /* copy data from selector, dir, and type to the pol_id */
memset(pol_id, 0, sizeof(*pol_id)); memset(pol_id, 0, sizeof(*pol_id));
memcpy(&pol_id->sel, sel, sizeof(pol_id->sel)); memcpy(&pol_id->sel, sel, sizeof(pol_id->sel));
...@@ -2041,8 +2041,8 @@ static int build_expire(struct sk_buff *skb, struct xfrm_state *x, struct km_eve ...@@ -2041,8 +2041,8 @@ static int build_expire(struct sk_buff *skb, struct xfrm_state *x, struct km_eve
nlh = nlmsg_put(skb, c->pid, 0, XFRM_MSG_EXPIRE, sizeof(*ue), 0); nlh = nlmsg_put(skb, c->pid, 0, XFRM_MSG_EXPIRE, sizeof(*ue), 0);
if (nlh == NULL) if (nlh == NULL)
return -EMSGSIZE; return -EMSGSIZE;
ue = NLMSG_DATA(nlh);
ue = nlmsg_data(nlh);
copy_to_user_state(x, &ue->state); copy_to_user_state(x, &ue->state);
ue->hard = (c->data.hard != 0) ? 1 : 0; ue->hard = (c->data.hard != 0) ? 1 : 0;
...@@ -2100,7 +2100,7 @@ static int xfrm_notify_sa_flush(struct km_event *c) ...@@ -2100,7 +2100,7 @@ static int xfrm_notify_sa_flush(struct km_event *c)
return -EMSGSIZE; return -EMSGSIZE;
} }
p = NLMSG_DATA(nlh); p = nlmsg_data(nlh);
p->proto = c->data.proto; p->proto = c->data.proto;
nlmsg_end(skb, nlh); nlmsg_end(skb, nlh);
...@@ -2148,9 +2148,9 @@ static int xfrm_notify_sa(struct xfrm_state *x, struct km_event *c) ...@@ -2148,9 +2148,9 @@ static int xfrm_notify_sa(struct xfrm_state *x, struct km_event *c)
if (nlh == NULL) if (nlh == NULL)
goto nlmsg_failure; goto nlmsg_failure;
p = NLMSG_DATA(nlh); p = nlmsg_data(nlh);
if (c->event == XFRM_MSG_DELSA) { if (c->event == XFRM_MSG_DELSA) {
id = NLMSG_DATA(nlh); id = nlmsg_data(nlh);
memcpy(&id->daddr, &x->id.daddr, sizeof(id->daddr)); memcpy(&id->daddr, &x->id.daddr, sizeof(id->daddr));
id->spi = x->id.spi; id->spi = x->id.spi;
id->family = x->props.family; id->family = x->props.family;
...@@ -2218,8 +2218,8 @@ static int build_acquire(struct sk_buff *skb, struct xfrm_state *x, ...@@ -2218,8 +2218,8 @@ static int build_acquire(struct sk_buff *skb, struct xfrm_state *x,
nlh = nlmsg_put(skb, 0, 0, XFRM_MSG_ACQUIRE, sizeof(*ua), 0); nlh = nlmsg_put(skb, 0, 0, XFRM_MSG_ACQUIRE, sizeof(*ua), 0);
if (nlh == NULL) if (nlh == NULL)
return -EMSGSIZE; return -EMSGSIZE;
ua = NLMSG_DATA(nlh);
ua = nlmsg_data(nlh);
memcpy(&ua->id, &x->id, sizeof(ua->id)); memcpy(&ua->id, &x->id, sizeof(ua->id));
memcpy(&ua->saddr, &x->props.saddr, sizeof(ua->saddr)); memcpy(&ua->saddr, &x->props.saddr, sizeof(ua->saddr));
memcpy(&ua->sel, &x->sel, sizeof(ua->sel)); memcpy(&ua->sel, &x->sel, sizeof(ua->sel));
...@@ -2335,8 +2335,8 @@ static int build_polexpire(struct sk_buff *skb, struct xfrm_policy *xp, ...@@ -2335,8 +2335,8 @@ static int build_polexpire(struct sk_buff *skb, struct xfrm_policy *xp,
nlh = nlmsg_put(skb, c->pid, 0, XFRM_MSG_POLEXPIRE, sizeof(*upe), 0); nlh = nlmsg_put(skb, c->pid, 0, XFRM_MSG_POLEXPIRE, sizeof(*upe), 0);
if (nlh == NULL) if (nlh == NULL)
return -EMSGSIZE; return -EMSGSIZE;
upe = NLMSG_DATA(nlh);
upe = nlmsg_data(nlh);
copy_to_user_policy(xp, &upe->pol, dir); copy_to_user_policy(xp, &upe->pol, dir);
if (copy_to_user_tmpl(xp, skb) < 0) if (copy_to_user_tmpl(xp, skb) < 0)
goto nlmsg_failure; goto nlmsg_failure;
...@@ -2402,9 +2402,9 @@ static int xfrm_notify_policy(struct xfrm_policy *xp, int dir, struct km_event * ...@@ -2402,9 +2402,9 @@ static int xfrm_notify_policy(struct xfrm_policy *xp, int dir, struct km_event *
if (nlh == NULL) if (nlh == NULL)
goto nlmsg_failure; goto nlmsg_failure;
p = NLMSG_DATA(nlh); p = nlmsg_data(nlh);
if (c->event == XFRM_MSG_DELPOLICY) { if (c->event == XFRM_MSG_DELPOLICY) {
id = NLMSG_DATA(nlh); id = nlmsg_data(nlh);
memset(id, 0, sizeof(*id)); memset(id, 0, sizeof(*id));
id->dir = dir; id->dir = dir;
if (c->data.byid) if (c->data.byid)
...@@ -2491,8 +2491,8 @@ static int build_report(struct sk_buff *skb, u8 proto, ...@@ -2491,8 +2491,8 @@ static int build_report(struct sk_buff *skb, u8 proto,
nlh = nlmsg_put(skb, 0, 0, XFRM_MSG_REPORT, sizeof(*ur), 0); nlh = nlmsg_put(skb, 0, 0, XFRM_MSG_REPORT, sizeof(*ur), 0);
if (nlh == NULL) if (nlh == NULL)
return -EMSGSIZE; return -EMSGSIZE;
ur = NLMSG_DATA(nlh);
ur = nlmsg_data(nlh);
ur->proto = proto; ur->proto = proto;
memcpy(&ur->sel, sel, sizeof(ur->sel)); memcpy(&ur->sel, sel, sizeof(ur->sel));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment