[IPV6] ADDRCONF: Convert ipv6_get_saddr() to ipv6_dev_get_saddr().
[deliverable/linux.git] / net / ipv6 / af_inet6.c
index f0aa977387462dc05f6a5e2ca12afe2b51283bc3..73021d5baece63804a8253948f4f402ac1342c03 100644 (file)
@@ -678,6 +678,129 @@ int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb)
 
 EXPORT_SYMBOL_GPL(ipv6_opt_accepted);
 
+static struct inet6_protocol *ipv6_gso_pull_exthdrs(struct sk_buff *skb,
+                                                   int proto)
+{
+       struct inet6_protocol *ops = NULL;
+
+       for (;;) {
+               struct ipv6_opt_hdr *opth;
+               int len;
+
+               if (proto != NEXTHDR_HOP) {
+                       ops = rcu_dereference(inet6_protos[proto]);
+
+                       if (unlikely(!ops))
+                               break;
+
+                       if (!(ops->flags & INET6_PROTO_GSO_EXTHDR))
+                               break;
+               }
+
+               if (unlikely(!pskb_may_pull(skb, 8)))
+                       break;
+
+               opth = (void *)skb->data;
+               len = ipv6_optlen(opth);
+
+               if (unlikely(!pskb_may_pull(skb, len)))
+                       break;
+
+               proto = opth->nexthdr;
+               __skb_pull(skb, len);
+       }
+
+       return ops;
+}
+
+static int ipv6_gso_send_check(struct sk_buff *skb)
+{
+       struct ipv6hdr *ipv6h;
+       struct inet6_protocol *ops;
+       int err = -EINVAL;
+
+       if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h))))
+               goto out;
+
+       ipv6h = ipv6_hdr(skb);
+       __skb_pull(skb, sizeof(*ipv6h));
+       err = -EPROTONOSUPPORT;
+
+       rcu_read_lock();
+       ops = ipv6_gso_pull_exthdrs(skb, ipv6h->nexthdr);
+       if (likely(ops && ops->gso_send_check)) {
+               skb_reset_transport_header(skb);
+               err = ops->gso_send_check(skb);
+       }
+       rcu_read_unlock();
+
+out:
+       return err;
+}
+
+static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, int features)
+{
+       struct sk_buff *segs = ERR_PTR(-EINVAL);
+       struct ipv6hdr *ipv6h;
+       struct inet6_protocol *ops;
+
+       if (!(features & NETIF_F_V6_CSUM))
+               features &= ~NETIF_F_SG;
+
+       if (unlikely(skb_shinfo(skb)->gso_type &
+                    ~(SKB_GSO_UDP |
+                      SKB_GSO_DODGY |
+                      SKB_GSO_TCP_ECN |
+                      SKB_GSO_TCPV6 |
+                      0)))
+               goto out;
+
+       if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h))))
+               goto out;
+
+       ipv6h = ipv6_hdr(skb);
+       __skb_pull(skb, sizeof(*ipv6h));
+       segs = ERR_PTR(-EPROTONOSUPPORT);
+
+       rcu_read_lock();
+       ops = ipv6_gso_pull_exthdrs(skb, ipv6h->nexthdr);
+       if (likely(ops && ops->gso_segment)) {
+               skb_reset_transport_header(skb);
+               segs = ops->gso_segment(skb, features);
+       }
+       rcu_read_unlock();
+
+       if (unlikely(IS_ERR(segs)))
+               goto out;
+
+       for (skb = segs; skb; skb = skb->next) {
+               ipv6h = ipv6_hdr(skb);
+               ipv6h->payload_len = htons(skb->len - skb->mac_len -
+                                          sizeof(*ipv6h));
+       }
+
+out:
+       return segs;
+}
+
+static struct packet_type ipv6_packet_type = {
+       .type = __constant_htons(ETH_P_IPV6),
+       .func = ipv6_rcv,
+       .gso_send_check = ipv6_gso_send_check,
+       .gso_segment = ipv6_gso_segment,
+};
+
+static int __init ipv6_packet_init(void)
+{
+       dev_add_pack(&ipv6_packet_type);
+       return 0;
+}
+
+static void ipv6_packet_cleanup(void)
+{
+       dev_remove_pack(&ipv6_packet_type);
+}
+
 static int __init init_ipv6_mibs(void)
 {
        if (snmp_mib_init((void **)ipv6_statistics,
@@ -691,12 +814,16 @@ static int __init init_ipv6_mibs(void)
                goto err_icmpmsg_mib;
        if (snmp_mib_init((void **)udp_stats_in6, sizeof (struct udp_mib)) < 0)
                goto err_udp_mib;
+#ifdef CONFIG_IP_UDPLITE
        if (snmp_mib_init((void **)udplite_stats_in6,
                          sizeof (struct udp_mib)) < 0)
                goto err_udplite_mib;
+#endif
        return 0;
 
+#ifdef CONFIG_IP_UDPLITE
 err_udplite_mib:
+#endif
        snmp_mib_free((void **)udp_stats_in6);
 err_udp_mib:
        snmp_mib_free((void **)icmpv6msg_statistics);
@@ -715,7 +842,9 @@ static void cleanup_ipv6_mibs(void)
        snmp_mib_free((void **)icmpv6_statistics);
        snmp_mib_free((void **)icmpv6msg_statistics);
        snmp_mib_free((void **)udp_stats_in6);
+#ifdef CONFIG_IP_UDPLITE
        snmp_mib_free((void **)udplite_stats_in6);
+#endif
 }
 
 static int inet6_net_init(struct net *net)
@@ -760,9 +889,11 @@ static int __init inet6_init(void)
        if (err)
                goto out_unregister_tcp_proto;
 
+#ifdef CONFIG_IP_UDPLITE
        err = proto_register(&udplitev6_prot, 1);
        if (err)
                goto out_unregister_udp_proto;
+#endif
 
        err = proto_register(&rawv6_prot, 1);
        if (err)
@@ -808,13 +939,13 @@ static int __init inet6_init(void)
        if (err)
                goto sysctl_fail;
 #endif
-       err = icmpv6_init(&inet6_family_ops);
+       err = icmpv6_init();
        if (err)
                goto icmp_fail;
-       err = ndisc_init(&inet6_family_ops);
+       err = ndisc_init();
        if (err)
                goto ndisc_fail;
-       err = igmp6_init(&inet6_family_ops);
+       err = igmp6_init();
        if (err)
                goto igmp_fail;
        err = ipv6_netfilter_init();
@@ -933,8 +1064,10 @@ out_sock_register_fail:
 out_unregister_raw_proto:
        proto_unregister(&rawv6_prot);
 out_unregister_udplite_proto:
+#ifdef CONFIG_IP_UDPLITE
        proto_unregister(&udplitev6_prot);
 out_unregister_udp_proto:
+#endif
        proto_unregister(&udpv6_prot);
 out_unregister_tcp_proto:
        proto_unregister(&tcpv6_prot);
@@ -950,7 +1083,9 @@ static void __exit inet6_exit(void)
        rtnl_unregister_all(PF_INET6);
 
        udpv6_exit();
+#ifdef CONFIG_IP_UDPLITE
        udplitev6_exit();
+#endif
        tcpv6_exit();
 
        /* Cleanup code parts. */
@@ -982,7 +1117,9 @@ static void __exit inet6_exit(void)
        unregister_pernet_subsys(&inet6_net_ops);
        cleanup_ipv6_mibs();
        proto_unregister(&rawv6_prot);
+#ifdef CONFIG_IP_UDPLITE
        proto_unregister(&udplitev6_prot);
+#endif
        proto_unregister(&udpv6_prot);
        proto_unregister(&tcpv6_prot);
 }
This page took 0.04018 seconds and 5 git commands to generate.