aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorYOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@linux-ipv6.org>2013-01-21 01:48:19 -0500
committerDavid S. Miller <davem@davemloft.net>2013-01-21 13:33:15 -0500
commit2576f17dfad402e2446244238ed22dddf35c2e53 (patch)
treec2f90411b0fc1d6bd8caf6b01a082cd56cb952cd /net
parentde09334b9326632bbf1a74bfd8b01866cbbf2f61 (diff)
ipv6: Unshare ip6_nd_hdr() and change return type to void.
- 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>
Diffstat (limited to 'net')
-rw-r--r--net/ipv6/ip6_output.c33
-rw-r--r--net/ipv6/mcast.c29
-rw-r--r--net/ipv6/ndisc.c25
3 files changed, 52 insertions, 35 deletions
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index b0895f5d5fc6..7eee94c27f8d 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -254,39 +254,6 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6,
254 254
255EXPORT_SYMBOL(ip6_xmit); 255EXPORT_SYMBOL(ip6_xmit);
256 256
257/*
258 * To avoid extra problems ND packets are send through this
259 * routine. It's code duplication but I really want to avoid
260 * extra checks since ipv6_build_header is used by TCP (which
261 * is for us performance critical)
262 */
263
264int ip6_nd_hdr(struct sock *sk, struct sk_buff *skb, struct net_device *dev,
265 const struct in6_addr *saddr, const struct in6_addr *daddr,
266 int proto, int len)
267{
268 struct ipv6_pinfo *np = inet6_sk(sk);
269 struct ipv6hdr *hdr;
270
271 skb->protocol = htons(ETH_P_IPV6);
272 skb->dev = dev;
273
274 skb_reset_network_header(skb);
275 skb_put(skb, sizeof(struct ipv6hdr));
276 hdr = ipv6_hdr(skb);
277
278 ip6_flow_hdr(hdr, 0, 0);
279
280 hdr->payload_len = htons(len);
281 hdr->nexthdr = proto;
282 hdr->hop_limit = np->hop_limit;
283
284 hdr->saddr = *saddr;
285 hdr->daddr = *daddr;
286
287 return 0;
288}
289
290static int ip6_call_ra_chain(struct sk_buff *skb, int sel) 257static int ip6_call_ra_chain(struct sk_buff *skb, int sel)
291{ 258{
292 struct ip6_ra_chain *ra; 259 struct ip6_ra_chain *ra;
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 587a84530a57..f25002aaf624 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -1313,6 +1313,31 @@ mld_scount(struct ifmcaddr6 *pmc, int type, int gdeleted, int sdeleted)
1313 return scount; 1313 return scount;
1314} 1314}
1315 1315
1316static void ip6_mc_hdr(struct sock *sk, struct sk_buff *skb,
1317 struct net_device *dev,
1318 const struct in6_addr *saddr,
1319 const struct in6_addr *daddr,
1320 int proto, int len)
1321{
1322 struct ipv6hdr *hdr;
1323
1324 skb->protocol = htons(ETH_P_IPV6);
1325 skb->dev = dev;
1326
1327 skb_reset_network_header(skb);
1328 skb_put(skb, sizeof(struct ipv6hdr));
1329 hdr = ipv6_hdr(skb);
1330
1331 ip6_flow_hdr(hdr, 0, 0);
1332
1333 hdr->payload_len = htons(len);
1334 hdr->nexthdr = proto;
1335 hdr->hop_limit = inet6_sk(sk)->hop_limit;
1336
1337 hdr->saddr = *saddr;
1338 hdr->daddr = *daddr;
1339}
1340
1316static struct sk_buff *mld_newpack(struct net_device *dev, int size) 1341static struct sk_buff *mld_newpack(struct net_device *dev, int size)
1317{ 1342{
1318 struct net *net = dev_net(dev); 1343 struct net *net = dev_net(dev);
@@ -1348,7 +1373,7 @@ static struct sk_buff *mld_newpack(struct net_device *dev, int size)
1348 } else 1373 } else
1349 saddr = &addr_buf; 1374 saddr = &addr_buf;
1350 1375
1351 ip6_nd_hdr(sk, skb, dev, saddr, &mld2_all_mcr, NEXTHDR_HOP, 0); 1376 ip6_mc_hdr(sk, skb, dev, saddr, &mld2_all_mcr, NEXTHDR_HOP, 0);
1352 1377
1353 memcpy(skb_put(skb, sizeof(ra)), ra, sizeof(ra)); 1378 memcpy(skb_put(skb, sizeof(ra)), ra, sizeof(ra));
1354 1379
@@ -1740,7 +1765,7 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
1740 } else 1765 } else
1741 saddr = &addr_buf; 1766 saddr = &addr_buf;
1742 1767
1743 ip6_nd_hdr(sk, skb, dev, saddr, snd_addr, NEXTHDR_HOP, payload_len); 1768 ip6_mc_hdr(sk, skb, dev, saddr, snd_addr, NEXTHDR_HOP, payload_len);
1744 1769
1745 memcpy(skb_put(skb, sizeof(ra)), ra, sizeof(ra)); 1770 memcpy(skb_put(skb, sizeof(ra)), ra, sizeof(ra));
1746 1771
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 1776a0deee7f..7ce266f34cc7 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -389,6 +389,31 @@ static struct sk_buff *ndisc_alloc_skb(struct net_device *dev,
389 return skb; 389 return skb;
390} 390}
391 391
392static void ip6_nd_hdr(struct sock *sk,
393 struct sk_buff *skb, struct net_device *dev,
394 const struct in6_addr *saddr,
395 const struct in6_addr *daddr,
396 int proto, int len)
397{
398 struct ipv6hdr *hdr;
399
400 skb->protocol = htons(ETH_P_IPV6);
401 skb->dev = dev;
402
403 skb_reset_network_header(skb);
404 skb_put(skb, sizeof(struct ipv6hdr));
405 hdr = ipv6_hdr(skb);
406
407 ip6_flow_hdr(hdr, 0, 0);
408
409 hdr->payload_len = htons(len);
410 hdr->nexthdr = proto;
411 hdr->hop_limit = inet6_sk(sk)->hop_limit;
412
413 hdr->saddr = *saddr;
414 hdr->daddr = *daddr;
415}
416
392static struct sk_buff *ndisc_build_skb(struct net_device *dev, 417static struct sk_buff *ndisc_build_skb(struct net_device *dev,
393 const struct in6_addr *daddr, 418 const struct in6_addr *daddr,
394 const struct in6_addr *saddr, 419 const struct in6_addr *saddr,