From: "Denis V. Lunev" <den@openvz.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, "Denis V. Lunev" <den@openvz.org>
Subject: [PATCH 2/4 net-2.6.26] [IPV4]: Cleanup ip_options_compile.
Date: Mon, 3 Mar 2008 18:48:41 +0300 [thread overview]
Message-ID: <1204559323-19953-2-git-send-email-den@openvz.org> (raw)
In-Reply-To: <1204559323-19953-1-git-send-email-den@openvz.org>
Right now ip_options_compile is called twice as (NULL, skb) and (opt, NULL).
So, let's move opt initialization into caller and remove this initialization
branch.
Additionally, the field ip_options->is_data becomes not needed. All decisions
should be made by the real skb availability.
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
include/net/inet_sock.h | 4 +---
net/ipv4/ip_input.c | 5 +++--
net/ipv4/ip_options.c | 24 +++++++-----------------
3 files changed, 11 insertions(+), 22 deletions(-)
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index 70013c5..e63714d 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -29,7 +29,6 @@
/** struct ip_options - IP Options
*
* @faddr - Saved first hop address
- * @is_data - Options in __data, rather than skb
* @is_strictroute - Strict source route
* @srr_is_hit - Packet destination addr was our one
* @is_changed - IP checksum more not valid
@@ -43,8 +42,7 @@ struct ip_options {
unsigned char srr;
unsigned char rr;
unsigned char ts;
- unsigned char is_data:1,
- is_strictroute:1,
+ unsigned char is_strictroute:1,
srr_is_hit:1,
is_changed:1,
rr_needaddr:1,
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index 6563139..3dbdb0c 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -284,12 +284,13 @@ static inline int ip_rcv_options(struct sk_buff *skb)
iph = ip_hdr(skb);
- if (ip_options_compile(NULL, skb)) {
+ opt = &(IPCB(skb)->opt);
+ opt->optlen = iph->ihl*4 - sizeof(struct iphdr);
+ if (ip_options_compile(opt, skb)) {
IP_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS);
goto drop;
}
- opt = &(IPCB(skb)->opt);
if (unlikely(opt->srr)) {
struct in_device *in_dev = in_dev_get(dev);
if (in_dev) {
diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c
index baaedd9..c49aa79 100644
--- a/net/ipv4/ip_options.c
+++ b/net/ipv4/ip_options.c
@@ -45,7 +45,6 @@ void ip_options_build(struct sk_buff * skb, struct ip_options * opt,
memcpy(&(IPCB(skb)->opt), opt, sizeof(struct ip_options));
memcpy(iph+sizeof(struct iphdr), opt->__data, opt->optlen);
opt = &(IPCB(skb)->opt);
- opt->is_data = 0;
if (opt->srr)
memcpy(iph+opt->srr+iph[opt->srr+1]-4, &daddr, 4);
@@ -95,8 +94,6 @@ int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb)
memset(dopt, 0, sizeof(struct ip_options));
- dopt->is_data = 1;
-
sopt = &(IPCB(skb)->opt);
if (sopt->optlen == 0) {
@@ -248,7 +245,6 @@ void ip_options_fragment(struct sk_buff * skb)
/*
* Verify options and fill pointers in struct options.
* Caller should clear *opt, and set opt->data.
- * If opt == NULL, then skb->data should point to IP header.
*/
int ip_options_compile(struct ip_options * opt, struct sk_buff * skb)
@@ -258,19 +254,14 @@ int ip_options_compile(struct ip_options * opt, struct sk_buff * skb)
unsigned char * optptr;
int optlen;
unsigned char * pp_ptr = NULL;
- struct rtable *rt = skb ? (struct rtable*)skb->dst : NULL;
-
- if (!opt) {
- opt = &(IPCB(skb)->opt);
- iph = skb_network_header(skb);
- opt->optlen = ((struct iphdr *)iph)->ihl*4 - sizeof(struct iphdr);
- optptr = iph + sizeof(struct iphdr);
- opt->is_data = 0;
- } else {
- optptr = opt->is_data ? opt->__data :
- (unsigned char *)&(ip_hdr(skb)[1]);
- iph = optptr - sizeof(struct iphdr);
+ struct rtable *rt = NULL;
+
+ optptr = opt->__data;
+ if (skb != NULL) {
+ rt = (struct rtable*)skb->dst;
+ optptr = (unsigned char *)&(ip_hdr(skb)[1]);
}
+ iph = optptr - sizeof(struct iphdr);
for (l = opt->optlen; l > 0; ) {
switch (*optptr) {
@@ -520,7 +511,6 @@ static int ip_options_get_finish(struct ip_options **optp,
while (optlen & 3)
opt->__data[optlen++] = IPOPT_END;
opt->optlen = optlen;
- opt->is_data = 1;
if (optlen && ip_options_compile(opt, NULL)) {
kfree(opt);
return -EINVAL;
--
1.5.3.rc5
next prev parent reply other threads:[~2008-03-03 15:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-03 15:48 [PATCH 1/4 net-2.6.26] [IPV4]: skb->dst can't be NULL in ip_options_echo Denis V. Lunev
2008-03-03 15:48 ` Denis V. Lunev [this message]
2008-03-03 19:55 ` [PATCH 2/4 net-2.6.26] [IPV4]: Cleanup ip_options_compile David Miller
2008-03-03 20:54 ` Denis V. Lunev
2008-03-03 21:24 ` David Miller
2008-03-03 22:57 ` Denis V. Lunev
2008-03-03 23:02 ` David Miller
2008-03-03 15:48 ` [PATCH 3/4 net-2.6.26] [SCTP]: seq_printf format warning Denis V. Lunev
2008-03-03 17:39 ` YOSHIFUJI Hideaki / 吉藤英明
2008-03-03 17:53 ` [PATCH 3/4 net-2.6.26] [SCTP]: seq_printf format warning. (fixed) Denis V. Lunev
2008-03-03 19:56 ` David Miller
2008-03-03 18:41 ` [PATCH 3/4 net-2.6.26] [SCTP]: seq_printf format warning Vlad Yasevich
2008-03-03 15:48 ` [PATCH 4/4 net-2.6.26] [TCP]: Merge exit paths in tcp_v4_conn_request Denis V. Lunev
2008-03-03 19:59 ` David Miller
2008-03-03 19:50 ` [PATCH 1/4 net-2.6.26] [IPV4]: skb->dst can't be NULL in ip_options_echo David Miller
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=1204559323-19953-2-git-send-email-den@openvz.org \
--to=den@openvz.org \
--cc=davem@davemloft.net \
--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).