]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/ipv4/ip_options.c
[IPV4]: ip_route_input() annotations
[net-next-2.6.git] / net / ipv4 / ip_options.c
index d3f6c468faf43ac20e4a8e56e1d5325ca96f14e0..87f25486fd64907f056ba7cf997728ed8404a9e0 100644 (file)
@@ -11,6 +11,7 @@
  *             
  */
 
+#include <linux/capability.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <asm/uaccess.h>
@@ -23,6 +24,7 @@
 #include <net/ip.h>
 #include <net/icmp.h>
 #include <net/route.h>
+#include <net/cipso_ipv4.h>
 
 /* 
  * Write options to IP header, record destination address to
@@ -193,6 +195,13 @@ int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb)
                        dopt->is_strictroute = sopt->is_strictroute;
                }
        }
+       if (sopt->cipso) {
+               optlen  = sptr[sopt->cipso+1];
+               dopt->cipso = dopt->optlen+sizeof(struct iphdr);
+               memcpy(dptr, sptr+sopt->cipso, optlen);
+               dptr += optlen;
+               dopt->optlen += optlen;
+       }
        while (dopt->optlen & 3) {
                *dptr++ = IPOPT_END;
                dopt->optlen++;
@@ -208,7 +217,7 @@ int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb)
 
 void ip_options_fragment(struct sk_buff * skb) 
 {
-       unsigned char * optptr = skb->nh.raw;
+       unsigned char * optptr = skb->nh.raw + sizeof(struct iphdr);
        struct ip_options * opt = &(IPCB(skb)->opt);
        int  l = opt->optlen;
        int  optlen;
@@ -255,7 +264,6 @@ int ip_options_compile(struct ip_options * opt, struct sk_buff * skb)
 
        if (!opt) {
                opt = &(IPCB(skb)->opt);
-               memset(opt, 0, sizeof(struct ip_options));
                iph = skb->nh.raw;
                opt->optlen = ((struct iphdr *)iph)->ihl*4 - sizeof(struct iphdr);
                optptr = iph + sizeof(struct iphdr);
@@ -434,6 +442,17 @@ int ip_options_compile(struct ip_options * opt, struct sk_buff * skb)
                        if (optptr[2] == 0 && optptr[3] == 0)
                                opt->router_alert = optptr - iph;
                        break;
+                     case IPOPT_CIPSO:
+                       if (opt->cipso) {
+                               pp_ptr = optptr;
+                               goto error;
+                       }
+                       opt->cipso = optptr - iph;
+                       if (cipso_v4_validate(&optptr)) {
+                               pp_ptr = optptr;
+                               goto error;
+                       }
+                       break;
                      case IPOPT_SEC:
                      case IPOPT_SID:
                      default:
@@ -506,7 +525,6 @@ static int ip_options_get_finish(struct ip_options **optp,
                opt->__data[optlen++] = IPOPT_END;
        opt->optlen = optlen;
        opt->is_data = 1;
-       opt->is_setbyuser = 1;
        if (optlen && ip_options_compile(opt, NULL)) {
                kfree(opt);
                return -EINVAL;
@@ -589,7 +607,7 @@ int ip_options_rcv_srr(struct sk_buff *skb)
 {
        struct ip_options *opt = &(IPCB(skb)->opt);
        int srrspace, srrptr;
-       u32 nexthop;
+       __be32 nexthop;
        struct iphdr *iph = skb->nh.iph;
        unsigned char * optptr = skb->nh.raw + opt->srr;
        struct rtable *rt = (struct rtable*)skb->dst;