From: Patrick McHardy <kaber@trash.net>
To: Herbert Xu <herbert.xu@redhat.com>,
"David S. Miller" <davem@davemloft.net>,
Linux Netdev List <netdev@vger.kernel.org>
Subject: gre: minor cleanups in netlink interface
Date: Fri, 10 Oct 2008 18:04:52 +0200 [thread overview]
Message-ID: <48EF7D24.6040400@trash.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 390 bytes --]
Some minor cleanups, there doesn't seem to be a reason for not
using the typeful helpers everywhere.
I noticed the interface expects to always get a full configuration
on change requests. Is there are particular reason for not
supporting incremental changes, lets say
"ip link change dev gre0 type gre remote <new remote>"
? It looks easy enough to change, so I could take care of this.
[-- Attachment #2: 02.diff --]
[-- Type: text/x-patch, Size: 2454 bytes --]
commit 5a00d521ffc35f3168bf72b9f0e398ae60793c50
Author: Patrick McHardy <kaber@trash.net>
Date: Fri Oct 10 17:58:17 2008 +0200
gre: minor cleanups in netlink interface
- use typeful helpers for IFLA_GRE_LOCAL/IFLA_GRE_REMOTE
- replace magic value by FIELD_SIZEOF
- use MODULE_ALIAS_RTNL_LINK macro
Signed-off-by: Patrick McHardy <kaber@trash.net>
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index c0755e9..05ebce2 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -1368,10 +1368,10 @@ static void ipgre_netlink_parms(struct nlattr *data[],
parms->o_key = nla_get_be32(data[IFLA_GRE_OKEY]);
if (data[IFLA_GRE_LOCAL])
- memcpy(&parms->iph.saddr, nla_data(data[IFLA_GRE_LOCAL]), 4);
+ parms->iph.saddr = nla_get_be32(data[IFLA_GRE_LOCAL]);
if (data[IFLA_GRE_REMOTE])
- memcpy(&parms->iph.daddr, nla_data(data[IFLA_GRE_REMOTE]), 4);
+ parms->iph.daddr = nla_get_be32(data[IFLA_GRE_REMOTE]);
if (data[IFLA_GRE_TTL])
parms->iph.ttl = nla_get_u8(data[IFLA_GRE_TTL]);
@@ -1541,8 +1541,8 @@ static int ipgre_fill_info(struct sk_buff *skb, const struct net_device *dev)
NLA_PUT_BE16(skb, IFLA_GRE_OFLAGS, p->o_flags);
NLA_PUT_BE32(skb, IFLA_GRE_IKEY, p->i_key);
NLA_PUT_BE32(skb, IFLA_GRE_OKEY, p->o_key);
- NLA_PUT(skb, IFLA_GRE_LOCAL, 4, &p->iph.saddr);
- NLA_PUT(skb, IFLA_GRE_REMOTE, 4, &p->iph.daddr);
+ NLA_PUT_BE32(skb, IFLA_GRE_LOCAL, p->iph.saddr);
+ NLA_PUT_BE32(skb, IFLA_GRE_REMOTE, p->iph.daddr);
NLA_PUT_U8(skb, IFLA_GRE_TTL, p->iph.ttl);
NLA_PUT_U8(skb, IFLA_GRE_TOS, p->iph.tos);
NLA_PUT_U8(skb, IFLA_GRE_PMTUDISC, !!(p->iph.frag_off & htons(IP_DF)));
@@ -1559,8 +1559,8 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
[IFLA_GRE_OFLAGS] = { .type = NLA_U16 },
[IFLA_GRE_IKEY] = { .type = NLA_U32 },
[IFLA_GRE_OKEY] = { .type = NLA_U32 },
- [IFLA_GRE_LOCAL] = { .len = 4 },
- [IFLA_GRE_REMOTE] = { .len = 4 },
+ [IFLA_GRE_LOCAL] = { .len = FIELD_SIZEOF(struct iphdr, saddr) },
+ [IFLA_GRE_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
[IFLA_GRE_TTL] = { .type = NLA_U8 },
[IFLA_GRE_TOS] = { .type = NLA_U8 },
[IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
@@ -1643,5 +1643,5 @@ static void __exit ipgre_fini(void)
module_init(ipgre_init);
module_exit(ipgre_fini);
MODULE_LICENSE("GPL");
-MODULE_ALIAS("rtnl-link-gre");
-MODULE_ALIAS("rtnl-link-gretap");
+MODULE_ALIAS_RTNL_LINK("gre");
+MODULE_ALIAS_RTNL_LINK("gretap");
next reply other threads:[~2008-10-10 16:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-10 16:04 Patrick McHardy [this message]
2008-10-10 19:11 ` gre: minor cleanups in netlink interface David Miller
2008-10-11 10:39 ` Herbert Xu
2008-10-11 12:43 ` Herbert Xu
2008-10-11 19:20 ` David Miller
2008-10-11 14:43 ` Patrick McHardy
2008-10-11 14:45 ` Patrick McHardy
2008-10-11 15:18 ` Herbert Xu
2008-10-11 15:39 ` Patrick McHardy
2008-10-11 15:03 ` Herbert Xu
2008-10-11 15:15 ` Patrick McHardy
2008-10-11 15:26 ` Herbert Xu
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=48EF7D24.6040400@trash.net \
--to=kaber@trash.net \
--cc=davem@davemloft.net \
--cc=herbert.xu@redhat.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).