ipv6: Unshare ip6_nd_hdr() and change return type to void.
authorYOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@linux-ipv6.org>
Mon, 21 Jan 2013 06:48:19 +0000 (06:48 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 21 Jan 2013 18:33:15 +0000 (13:33 -0500)
- move ip6_nd_hdr() to its users' source files.
  In net/ipv6/mcast.c, it will be called ip6_mc_hdr().
- make return type to void since this function never fails.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/ipv6.h
net/ipv6/ip6_output.c
net/ipv6/mcast.c
net/ipv6/ndisc.c

index 464c6f7..c1878f7 100644 (file)
@@ -661,13 +661,6 @@ extern int                 ip6_xmit(struct sock *sk,
                                         struct ipv6_txoptions *opt,
                                         int tclass);
 
-extern int                     ip6_nd_hdr(struct sock *sk,
-                                          struct sk_buff *skb,
-                                          struct net_device *dev,
-                                          const struct in6_addr *saddr,
-                                          const struct in6_addr *daddr,
-                                          int proto, int len);
-
 extern int                     ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr);
 
 extern int                     ip6_append_data(struct sock *sk,
index b0895f5..7eee94c 100644 (file)
@@ -254,39 +254,6 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6,
 
 EXPORT_SYMBOL(ip6_xmit);
 
-/*
- *     To avoid extra problems ND packets are send through this
- *     routine. It's code duplication but I really want to avoid
- *     extra checks since ipv6_build_header is used by TCP (which
- *     is for us performance critical)
- */
-
-int ip6_nd_hdr(struct sock *sk, struct sk_buff *skb, struct net_device *dev,
-              const struct in6_addr *saddr, const struct in6_addr *daddr,
-              int proto, int len)
-{
-       struct ipv6_pinfo *np = inet6_sk(sk);
-       struct ipv6hdr *hdr;
-
-       skb->protocol = htons(ETH_P_IPV6);
-       skb->dev = dev;
-
-       skb_reset_network_header(skb);
-       skb_put(skb, sizeof(struct ipv6hdr));
-       hdr = ipv6_hdr(skb);
-
-       ip6_flow_hdr(hdr, 0, 0);
-
-       hdr->payload_len = htons(len);
-       hdr->nexthdr = proto;
-       hdr->hop_limit = np->hop_limit;
-
-       hdr->saddr = *saddr;
-       hdr->daddr = *daddr;
-
-       return 0;
-}
-
 static int ip6_call_ra_chain(struct sk_buff *skb, int sel)
 {
        struct ip6_ra_chain *ra;
index 587a845..f25002a 100644 (file)
@@ -1313,6 +1313,31 @@ mld_scount(struct ifmcaddr6 *pmc, int type, int gdeleted, int sdeleted)
        return scount;
 }
 
+static void ip6_mc_hdr(struct sock *sk, struct sk_buff *skb,
+                      struct net_device *dev,
+                      const struct in6_addr *saddr,
+                      const struct in6_addr *daddr,
+                      int proto, int len)
+{
+       struct ipv6hdr *hdr;
+
+       skb->protocol = htons(ETH_P_IPV6);
+       skb->dev = dev;
+
+       skb_reset_network_header(skb);
+       skb_put(skb, sizeof(struct ipv6hdr));
+       hdr = ipv6_hdr(skb);
+
+       ip6_flow_hdr(hdr, 0, 0);
+
+       hdr->payload_len = htons(len);
+       hdr->nexthdr = proto;
+       hdr->hop_limit = inet6_sk(sk)->hop_limit;
+
+       hdr->saddr = *saddr;
+       hdr->daddr = *daddr;
+}
+
 static struct sk_buff *mld_newpack(struct net_device *dev, int size)
 {
        struct net *net = dev_net(dev);
@@ -1348,7 +1373,7 @@ static struct sk_buff *mld_newpack(struct net_device *dev, int size)
        } else
                saddr = &addr_buf;
 
-       ip6_nd_hdr(sk, skb, dev, saddr, &mld2_all_mcr, NEXTHDR_HOP, 0);
+       ip6_mc_hdr(sk, skb, dev, saddr, &mld2_all_mcr, NEXTHDR_HOP, 0);
 
        memcpy(skb_put(skb, sizeof(ra)), ra, sizeof(ra));
 
@@ -1740,7 +1765,7 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
        } else
                saddr = &addr_buf;
 
-       ip6_nd_hdr(sk, skb, dev, saddr, snd_addr, NEXTHDR_HOP, payload_len);
+       ip6_mc_hdr(sk, skb, dev, saddr, snd_addr, NEXTHDR_HOP, payload_len);
 
        memcpy(skb_put(skb, sizeof(ra)), ra, sizeof(ra));
 
index 1776a0d..7ce266f 100644 (file)
@@ -389,6 +389,31 @@ static struct sk_buff *ndisc_alloc_skb(struct net_device *dev,
        return skb;
 }
 
+static void ip6_nd_hdr(struct sock *sk,
+                      struct sk_buff *skb, struct net_device *dev,
+                      const struct in6_addr *saddr,
+                      const struct in6_addr *daddr,
+                      int proto, int len)
+{
+       struct ipv6hdr *hdr;
+
+       skb->protocol = htons(ETH_P_IPV6);
+       skb->dev = dev;
+
+       skb_reset_network_header(skb);
+       skb_put(skb, sizeof(struct ipv6hdr));
+       hdr = ipv6_hdr(skb);
+
+       ip6_flow_hdr(hdr, 0, 0);
+
+       hdr->payload_len = htons(len);
+       hdr->nexthdr = proto;
+       hdr->hop_limit = inet6_sk(sk)->hop_limit;
+
+       hdr->saddr = *saddr;
+       hdr->daddr = *daddr;
+}
+
 static struct sk_buff *ndisc_build_skb(struct net_device *dev,
                                       const struct in6_addr *daddr,
                                       const struct in6_addr *saddr,