[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1517386508-10915-3-git-send-email-serhe.popovych@gmail.com>
Date: Wed, 31 Jan 2018 10:15:07 +0200
From: Serhey Popovych <serhe.popovych@...il.com>
To: netdev@...r.kernel.org
Subject: [PATCH iproute2-next 2/3] ip: Minor cleanups
1) Rename @hdr parameter to @n to be coherent with rest of the parsing
code.
2) Use NLMSG_DATA() to get pointer to the data after nlmsghdr instead
of calculating it directly in ip/tunnel code.
Signed-off-by: Serhey Popovych <serhe.popovych@...il.com>
---
ip/iplink_vxcan.c | 18 +++++++++---------
ip/ipmacsec.c | 28 ++++++++++++++--------------
ip/link_gre.c | 2 +-
ip/link_gre6.c | 2 +-
ip/link_ip6tnl.c | 2 +-
ip/link_iptnl.c | 2 +-
ip/link_veth.c | 18 +++++++++---------
ip/link_vti.c | 2 +-
ip/link_vti6.c | 2 +-
9 files changed, 38 insertions(+), 38 deletions(-)
diff --git a/ip/iplink_vxcan.c b/ip/iplink_vxcan.c
index ed0ad8b..87be5a6 100644
--- a/ip/iplink_vxcan.c
+++ b/ip/iplink_vxcan.c
@@ -31,7 +31,7 @@ static void usage(void)
}
static int vxcan_parse_opt(struct link_util *lu, int argc, char **argv,
- struct nlmsghdr *hdr)
+ struct nlmsghdr *n)
{
char *dev = NULL;
char *name = NULL;
@@ -49,18 +49,18 @@ static int vxcan_parse_opt(struct link_util *lu, int argc, char **argv,
return -1;
}
- ifm = NLMSG_DATA(hdr);
+ ifm = NLMSG_DATA(n);
ifi_flags = ifm->ifi_flags;
ifi_change = ifm->ifi_change;
ifm->ifi_flags = 0;
ifm->ifi_change = 0;
- data = NLMSG_TAIL(hdr);
- addattr_l(hdr, 1024, VXCAN_INFO_PEER, NULL, 0);
+ data = NLMSG_TAIL(n);
+ addattr_l(n, 1024, VXCAN_INFO_PEER, NULL, 0);
- hdr->nlmsg_len += sizeof(struct ifinfomsg);
+ n->nlmsg_len += sizeof(struct ifinfomsg);
- err = iplink_parse(argc - 1, argv + 1, (struct iplink_req *)hdr,
+ err = iplink_parse(argc - 1, argv + 1, (struct iplink_req *)n,
&name, &type, &link, &dev, &group, &index);
if (err < 0)
return err;
@@ -69,7 +69,7 @@ static int vxcan_parse_opt(struct link_util *lu, int argc, char **argv,
duparg("type", argv[err]);
if (name) {
- addattr_l(hdr, 1024,
+ addattr_l(n, 1024,
IFLA_IFNAME, name, strlen(name) + 1);
}
@@ -81,9 +81,9 @@ static int vxcan_parse_opt(struct link_util *lu, int argc, char **argv,
ifm->ifi_change = ifi_change;
if (group != -1)
- addattr32(hdr, 1024, IFLA_GROUP, group);
+ addattr32(n, 1024, IFLA_GROUP, group);
- data->rta_len = (void *)NLMSG_TAIL(hdr) - (void *)data;
+ data->rta_len = (void *)NLMSG_TAIL(n) - (void *)data;
return argc - 1 - err;
}
diff --git a/ip/ipmacsec.c b/ip/ipmacsec.c
index 345a707..c0b45f5 100644
--- a/ip/ipmacsec.c
+++ b/ip/ipmacsec.c
@@ -1132,7 +1132,7 @@ static void usage(FILE *f)
}
static int macsec_parse_opt(struct link_util *lu, int argc, char **argv,
- struct nlmsghdr *hdr)
+ struct nlmsghdr *n)
{
int ret;
__u8 encoding_sa = 0xff;
@@ -1151,10 +1151,10 @@ static int macsec_parse_opt(struct link_util *lu, int argc, char **argv,
if (ret > 0) {
if (sci.sci)
- addattr_l(hdr, MACSEC_BUFLEN, IFLA_MACSEC_SCI,
+ addattr_l(n, MACSEC_BUFLEN, IFLA_MACSEC_SCI,
&sci.sci, sizeof(sci.sci));
else
- addattr_l(hdr, MACSEC_BUFLEN, IFLA_MACSEC_PORT,
+ addattr_l(n, MACSEC_BUFLEN, IFLA_MACSEC_PORT,
&sci.port, sizeof(sci.port));
}
@@ -1183,7 +1183,7 @@ static int macsec_parse_opt(struct link_util *lu, int argc, char **argv,
ARRAY_SIZE(values_on_off), &i);
if (ret != 0)
return ret;
- addattr8(hdr, MACSEC_BUFLEN, IFLA_MACSEC_ENCRYPT, i);
+ addattr8(n, MACSEC_BUFLEN, IFLA_MACSEC_ENCRYPT, i);
} else if (strcmp(*argv, "send_sci") == 0) {
NEXT_ARG();
int i;
@@ -1193,7 +1193,7 @@ static int macsec_parse_opt(struct link_util *lu, int argc, char **argv,
if (ret != 0)
return ret;
send_sci = i;
- addattr8(hdr, MACSEC_BUFLEN,
+ addattr8(n, MACSEC_BUFLEN,
IFLA_MACSEC_INC_SCI, send_sci);
} else if (strcmp(*argv, "end_station") == 0) {
NEXT_ARG();
@@ -1204,7 +1204,7 @@ static int macsec_parse_opt(struct link_util *lu, int argc, char **argv,
if (ret != 0)
return ret;
es = i;
- addattr8(hdr, MACSEC_BUFLEN, IFLA_MACSEC_ES, es);
+ addattr8(n, MACSEC_BUFLEN, IFLA_MACSEC_ES, es);
} else if (strcmp(*argv, "scb") == 0) {
NEXT_ARG();
int i;
@@ -1214,7 +1214,7 @@ static int macsec_parse_opt(struct link_util *lu, int argc, char **argv,
if (ret != 0)
return ret;
scb = i;
- addattr8(hdr, MACSEC_BUFLEN, IFLA_MACSEC_SCB, scb);
+ addattr8(n, MACSEC_BUFLEN, IFLA_MACSEC_SCB, scb);
} else if (strcmp(*argv, "protect") == 0) {
NEXT_ARG();
int i;
@@ -1223,7 +1223,7 @@ static int macsec_parse_opt(struct link_util *lu, int argc, char **argv,
ARRAY_SIZE(values_on_off), &i);
if (ret != 0)
return ret;
- addattr8(hdr, MACSEC_BUFLEN, IFLA_MACSEC_PROTECT, i);
+ addattr8(n, MACSEC_BUFLEN, IFLA_MACSEC_PROTECT, i);
} else if (strcmp(*argv, "replay") == 0) {
NEXT_ARG();
int i;
@@ -1245,7 +1245,7 @@ static int macsec_parse_opt(struct link_util *lu, int argc, char **argv,
(int *)&validate);
if (ret != 0)
return ret;
- addattr8(hdr, MACSEC_BUFLEN,
+ addattr8(n, MACSEC_BUFLEN,
IFLA_MACSEC_VALIDATION, validate);
} else if (strcmp(*argv, "encodingsa") == 0) {
if (encoding_sa != 0xff)
@@ -1281,20 +1281,20 @@ static int macsec_parse_opt(struct link_util *lu, int argc, char **argv,
}
if (cipher.id)
- addattr_l(hdr, MACSEC_BUFLEN, IFLA_MACSEC_CIPHER_SUITE,
+ addattr_l(n, MACSEC_BUFLEN, IFLA_MACSEC_CIPHER_SUITE,
&cipher.id, sizeof(cipher.id));
if (cipher.icv_len)
- addattr_l(hdr, MACSEC_BUFLEN, IFLA_MACSEC_ICV_LEN,
+ addattr_l(n, MACSEC_BUFLEN, IFLA_MACSEC_ICV_LEN,
&cipher.icv_len, sizeof(cipher.icv_len));
if (replay_protect != -1) {
- addattr32(hdr, MACSEC_BUFLEN, IFLA_MACSEC_WINDOW, window);
- addattr8(hdr, MACSEC_BUFLEN, IFLA_MACSEC_REPLAY_PROTECT,
+ addattr32(n, MACSEC_BUFLEN, IFLA_MACSEC_WINDOW, window);
+ addattr8(n, MACSEC_BUFLEN, IFLA_MACSEC_REPLAY_PROTECT,
replay_protect);
}
if (encoding_sa != 0xff) {
- addattr_l(hdr, MACSEC_BUFLEN, IFLA_MACSEC_ENCODING_SA,
+ addattr_l(n, MACSEC_BUFLEN, IFLA_MACSEC_ENCODING_SA,
&encoding_sa, sizeof(encoding_sa));
}
diff --git a/ip/link_gre.c b/ip/link_gre.c
index 8fb8fe5..b2573a1 100644
--- a/ip/link_gre.c
+++ b/ip/link_gre.c
@@ -69,7 +69,7 @@ static void usage(void)
static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
struct nlmsghdr *n)
{
- struct ifinfomsg *ifi = (struct ifinfomsg *)(n + 1);
+ struct ifinfomsg *ifi = NLMSG_DATA(n);
struct {
struct nlmsghdr n;
struct ifinfomsg i;
diff --git a/ip/link_gre6.c b/ip/link_gre6.c
index 4045f65..880b75d 100644
--- a/ip/link_gre6.c
+++ b/ip/link_gre6.c
@@ -79,7 +79,7 @@ static void usage(void)
static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
struct nlmsghdr *n)
{
- struct ifinfomsg *ifi = (struct ifinfomsg *)(n + 1);
+ struct ifinfomsg *ifi = NLMSG_DATA(n);
struct {
struct nlmsghdr n;
struct ifinfomsg i;
diff --git a/ip/link_ip6tnl.c b/ip/link_ip6tnl.c
index ccc79ff..91d7d99 100644
--- a/ip/link_ip6tnl.c
+++ b/ip/link_ip6tnl.c
@@ -72,7 +72,7 @@ static void usage(void)
static int ip6tunnel_parse_opt(struct link_util *lu, int argc, char **argv,
struct nlmsghdr *n)
{
- struct ifinfomsg *ifi = (struct ifinfomsg *)(n + 1);
+ struct ifinfomsg *ifi = NLMSG_DATA(n);
struct {
struct nlmsghdr n;
struct ifinfomsg i;
diff --git a/ip/link_iptnl.c b/ip/link_iptnl.c
index 622c6f1..3e653b7 100644
--- a/ip/link_iptnl.c
+++ b/ip/link_iptnl.c
@@ -72,7 +72,7 @@ static void usage(int sit)
static int iptunnel_parse_opt(struct link_util *lu, int argc, char **argv,
struct nlmsghdr *n)
{
- struct ifinfomsg *ifi = (struct ifinfomsg *)(n + 1);
+ struct ifinfomsg *ifi = NLMSG_DATA(n);
struct {
struct nlmsghdr n;
struct ifinfomsg i;
diff --git a/ip/link_veth.c b/ip/link_veth.c
index fddb7ac..e6219e7 100644
--- a/ip/link_veth.c
+++ b/ip/link_veth.c
@@ -29,7 +29,7 @@ static void usage(void)
}
static int veth_parse_opt(struct link_util *lu, int argc, char **argv,
- struct nlmsghdr *hdr)
+ struct nlmsghdr *n)
{
char *dev = NULL;
char *name = NULL;
@@ -47,18 +47,18 @@ static int veth_parse_opt(struct link_util *lu, int argc, char **argv,
return -1;
}
- ifm = NLMSG_DATA(hdr);
+ ifm = NLMSG_DATA(n);
ifi_flags = ifm->ifi_flags;
ifi_change = ifm->ifi_change;
ifm->ifi_flags = 0;
ifm->ifi_change = 0;
- data = NLMSG_TAIL(hdr);
- addattr_l(hdr, 1024, VETH_INFO_PEER, NULL, 0);
+ data = NLMSG_TAIL(n);
+ addattr_l(n, 1024, VETH_INFO_PEER, NULL, 0);
- hdr->nlmsg_len += sizeof(struct ifinfomsg);
+ n->nlmsg_len += sizeof(struct ifinfomsg);
- err = iplink_parse(argc - 1, argv + 1, (struct iplink_req *)hdr,
+ err = iplink_parse(argc - 1, argv + 1, (struct iplink_req *)n,
&name, &type, &link, &dev, &group, &index);
if (err < 0)
return err;
@@ -67,7 +67,7 @@ static int veth_parse_opt(struct link_util *lu, int argc, char **argv,
duparg("type", argv[err]);
if (name) {
- addattr_l(hdr, 1024,
+ addattr_l(n, 1024,
IFLA_IFNAME, name, strlen(name) + 1);
}
@@ -79,9 +79,9 @@ static int veth_parse_opt(struct link_util *lu, int argc, char **argv,
ifm->ifi_change = ifi_change;
if (group != -1)
- addattr32(hdr, 1024, IFLA_GROUP, group);
+ addattr32(n, 1024, IFLA_GROUP, group);
- data->rta_len = (void *)NLMSG_TAIL(hdr) - (void *)data;
+ data->rta_len = (void *)NLMSG_TAIL(n) - (void *)data;
return argc - 1 - err;
}
diff --git a/ip/link_vti.c b/ip/link_vti.c
index a5b84a0..49b87e9 100644
--- a/ip/link_vti.c
+++ b/ip/link_vti.c
@@ -49,7 +49,7 @@ static void usage(void)
static int vti_parse_opt(struct link_util *lu, int argc, char **argv,
struct nlmsghdr *n)
{
- struct ifinfomsg *ifi = (struct ifinfomsg *)(n + 1);
+ struct ifinfomsg *ifi = NLMSG_DATA(n);
struct {
struct nlmsghdr n;
struct ifinfomsg i;
diff --git a/ip/link_vti6.c b/ip/link_vti6.c
index 39d12e6..d1fbec5 100644
--- a/ip/link_vti6.c
+++ b/ip/link_vti6.c
@@ -49,7 +49,7 @@ static void usage(void)
static int vti6_parse_opt(struct link_util *lu, int argc, char **argv,
struct nlmsghdr *n)
{
- struct ifinfomsg *ifi = (struct ifinfomsg *)(n + 1);
+ struct ifinfomsg *ifi = NLMSG_DATA(n);
struct {
struct nlmsghdr n;
struct ifinfomsg i;
--
1.7.10.4
Powered by blists - more mailing lists