mac80211: fix modprobe deadlock by not calling wep_init under rtnl_lock
[safe/jmp/linux-2.6] / net / ipv4 / ip_options.c
index f0949b4..2c88da6 100644 (file)
@@ -5,8 +5,6 @@
  *
  *             The options processing module for ip.c
  *
- * Version:    $Id: ip_options.c,v 1.21 2001/09/01 00:31:50 davem Exp $
- *
  * Authors:    A.N.Kuznetsov
  *
  */
@@ -55,10 +53,10 @@ void ip_options_build(struct sk_buff * skb, struct ip_options * opt,
                if (opt->ts_needaddr)
                        ip_rt_get_source(iph+opt->ts+iph[opt->ts+2]-9, rt);
                if (opt->ts_needtime) {
-                       struct timeval tv;
+                       struct timespec tv;
                        __be32 midtime;
-                       do_gettimeofday(&tv);
-                       midtime = htonl((tv.tv_sec % 86400) * 1000 + tv.tv_usec / 1000);
+                       getnstimeofday(&tv);
+                       midtime = htonl((tv.tv_sec % 86400) * MSEC_PER_SEC + tv.tv_nsec / NSEC_PER_MSEC);
                        memcpy(iph+opt->ts+iph[opt->ts+2]-5, &midtime, 4);
                }
                return;
@@ -145,7 +143,7 @@ int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb)
                                                __be32 addr;
 
                                                memcpy(&addr, sptr+soffset-1, 4);
-                                               if (inet_addr_type(&init_net, addr) != RTN_LOCAL) {
+                                               if (inet_addr_type(dev_net(skb->dst->dev), addr) != RTN_LOCAL) {
                                                        dopt->ts_needtime = 1;
                                                        soffset += 8;
                                                }
@@ -406,10 +404,10 @@ int ip_options_compile(struct net *net,
                                        break;
                                }
                                if (timeptr) {
-                                       struct timeval tv;
+                                       struct timespec tv;
                                        __be32  midtime;
-                                       do_gettimeofday(&tv);
-                                       midtime = htonl((tv.tv_sec % 86400) * 1000 + tv.tv_usec / 1000);
+                                       getnstimeofday(&tv);
+                                       midtime = htonl((tv.tv_sec % 86400) * MSEC_PER_SEC + tv.tv_nsec / NSEC_PER_MSEC);
                                        memcpy(timeptr, &midtime, sizeof(__be32));
                                        opt->is_changed = 1;
                                }
@@ -440,7 +438,7 @@ int ip_options_compile(struct net *net,
                                goto error;
                        }
                        opt->cipso = optptr - iph;
-                       if (cipso_v4_validate(&optptr)) {
+                       if (cipso_v4_validate(skb, &optptr)) {
                                pp_ptr = optptr;
                                goto error;
                        }
@@ -507,13 +505,13 @@ static struct ip_options *ip_options_get_alloc(const int optlen)
                       GFP_KERNEL);
 }
 
-static int ip_options_get_finish(struct ip_options **optp,
+static int ip_options_get_finish(struct net *net, struct ip_options **optp,
                                 struct ip_options *opt, int optlen)
 {
        while (optlen & 3)
                opt->__data[optlen++] = IPOPT_END;
        opt->optlen = optlen;
-       if (optlen && ip_options_compile(&init_net, opt, NULL)) {
+       if (optlen && ip_options_compile(net, opt, NULL)) {
                kfree(opt);
                return -EINVAL;
        }
@@ -522,7 +520,8 @@ static int ip_options_get_finish(struct ip_options **optp,
        return 0;
 }
 
-int ip_options_get_from_user(struct ip_options **optp, unsigned char __user *data, int optlen)
+int ip_options_get_from_user(struct net *net, struct ip_options **optp,
+                            unsigned char __user *data, int optlen)
 {
        struct ip_options *opt = ip_options_get_alloc(optlen);
 
@@ -532,10 +531,11 @@ int ip_options_get_from_user(struct ip_options **optp, unsigned char __user *dat
                kfree(opt);
                return -EFAULT;
        }
-       return ip_options_get_finish(optp, opt, optlen);
+       return ip_options_get_finish(net, optp, opt, optlen);
 }
 
-int ip_options_get(struct ip_options **optp, unsigned char *data, int optlen)
+int ip_options_get(struct net *net, struct ip_options **optp,
+                  unsigned char *data, int optlen)
 {
        struct ip_options *opt = ip_options_get_alloc(optlen);
 
@@ -543,7 +543,7 @@ int ip_options_get(struct ip_options **optp, unsigned char *data, int optlen)
                return -ENOMEM;
        if (optlen)
                memcpy(opt->__data, data, optlen);
-       return ip_options_get_finish(optp, opt, optlen);
+       return ip_options_get_finish(net, optp, opt, optlen);
 }
 
 void ip_forward_options(struct sk_buff *skb)