Skip to content

Commit

Permalink
[IPV4]: Always pass ip_options pointer into ip_options_compile.
Browse files Browse the repository at this point in the history
This makes code a bit more uniform and straigthforward.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Denis V. Lunev authored and David S. Miller committed Mar 22, 2008
1 parent ef72249 commit 22aba38
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
5 changes: 3 additions & 2 deletions net/ipv4/ip_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,14 @@ static inline int ip_rcv_options(struct sk_buff *skb)
}

iph = ip_hdr(skb);
opt = &(IPCB(skb)->opt);
opt->optlen = iph->ihl*4 - sizeof(struct iphdr);

if (ip_options_compile(NULL, skb)) {
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) {
Expand Down
17 changes: 7 additions & 10 deletions net/ipv4/ip_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,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 ? skb->rtable : 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);
} else {
struct rtable *rt = NULL;

if (skb != NULL) {
rt = skb->rtable;
optptr = (unsigned char *)&(ip_hdr(skb)[1]);
} else
optptr = opt->__data;
iph = optptr - sizeof(struct iphdr);
}
iph = optptr - sizeof(struct iphdr);

for (l = opt->optlen; l > 0; ) {
switch (*optptr) {
Expand Down

0 comments on commit 22aba38

Please sign in to comment.