diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2011-04-22 00:53:02 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-04-22 14:04:14 -0400 |
commit | b71d1d426d263b0b6cb5760322efebbfc89d4463 (patch) | |
tree | 226ca7390bd6187ec9139d2ccedd26fd94d8e57a /net/ipv6/sit.c | |
parent | 5f8629c526b4f7e529a6d27bbd802c0dc7fcc357 (diff) |
inet: constify ip headers and in6_addr
Add const qualifiers to structs iphdr, ipv6hdr and in6_addr pointers
where possible, to make code intention more obvious.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/sit.c')
-rw-r--r-- | net/ipv6/sit.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index 43b33373adb2..34d896426701 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c | |||
@@ -452,7 +452,7 @@ out: | |||
452 | } | 452 | } |
453 | 453 | ||
454 | static int | 454 | static int |
455 | isatap_chksrc(struct sk_buff *skb, struct iphdr *iph, struct ip_tunnel *t) | 455 | isatap_chksrc(struct sk_buff *skb, const struct iphdr *iph, struct ip_tunnel *t) |
456 | { | 456 | { |
457 | struct ip_tunnel_prl_entry *p; | 457 | struct ip_tunnel_prl_entry *p; |
458 | int ok = 1; | 458 | int ok = 1; |
@@ -465,7 +465,8 @@ isatap_chksrc(struct sk_buff *skb, struct iphdr *iph, struct ip_tunnel *t) | |||
465 | else | 465 | else |
466 | skb->ndisc_nodetype = NDISC_NODETYPE_NODEFAULT; | 466 | skb->ndisc_nodetype = NDISC_NODETYPE_NODEFAULT; |
467 | } else { | 467 | } else { |
468 | struct in6_addr *addr6 = &ipv6_hdr(skb)->saddr; | 468 | const struct in6_addr *addr6 = &ipv6_hdr(skb)->saddr; |
469 | |||
469 | if (ipv6_addr_is_isatap(addr6) && | 470 | if (ipv6_addr_is_isatap(addr6) && |
470 | (addr6->s6_addr32[3] == iph->saddr) && | 471 | (addr6->s6_addr32[3] == iph->saddr) && |
471 | ipv6_chk_prefix(addr6, t->dev)) | 472 | ipv6_chk_prefix(addr6, t->dev)) |
@@ -499,7 +500,7 @@ static int ipip6_err(struct sk_buff *skb, u32 info) | |||
499 | 8 bytes of packet payload. It means, that precise relaying of | 500 | 8 bytes of packet payload. It means, that precise relaying of |
500 | ICMP in the real Internet is absolutely infeasible. | 501 | ICMP in the real Internet is absolutely infeasible. |
501 | */ | 502 | */ |
502 | struct iphdr *iph = (struct iphdr*)skb->data; | 503 | const struct iphdr *iph = (const struct iphdr *)skb->data; |
503 | const int type = icmp_hdr(skb)->type; | 504 | const int type = icmp_hdr(skb)->type; |
504 | const int code = icmp_hdr(skb)->code; | 505 | const int code = icmp_hdr(skb)->code; |
505 | struct ip_tunnel *t; | 506 | struct ip_tunnel *t; |
@@ -557,7 +558,7 @@ out: | |||
557 | return err; | 558 | return err; |
558 | } | 559 | } |
559 | 560 | ||
560 | static inline void ipip6_ecn_decapsulate(struct iphdr *iph, struct sk_buff *skb) | 561 | static inline void ipip6_ecn_decapsulate(const struct iphdr *iph, struct sk_buff *skb) |
561 | { | 562 | { |
562 | if (INET_ECN_is_ce(iph->tos)) | 563 | if (INET_ECN_is_ce(iph->tos)) |
563 | IP6_ECN_set_ce(ipv6_hdr(skb)); | 564 | IP6_ECN_set_ce(ipv6_hdr(skb)); |
@@ -565,7 +566,7 @@ static inline void ipip6_ecn_decapsulate(struct iphdr *iph, struct sk_buff *skb) | |||
565 | 566 | ||
566 | static int ipip6_rcv(struct sk_buff *skb) | 567 | static int ipip6_rcv(struct sk_buff *skb) |
567 | { | 568 | { |
568 | struct iphdr *iph; | 569 | const struct iphdr *iph; |
569 | struct ip_tunnel *tunnel; | 570 | struct ip_tunnel *tunnel; |
570 | 571 | ||
571 | if (!pskb_may_pull(skb, sizeof(struct ipv6hdr))) | 572 | if (!pskb_may_pull(skb, sizeof(struct ipv6hdr))) |
@@ -621,7 +622,7 @@ out: | |||
621 | * comes from 6rd / 6to4 (RFC 3056) addr space. | 622 | * comes from 6rd / 6to4 (RFC 3056) addr space. |
622 | */ | 623 | */ |
623 | static inline | 624 | static inline |
624 | __be32 try_6rd(struct in6_addr *v6dst, struct ip_tunnel *tunnel) | 625 | __be32 try_6rd(const struct in6_addr *v6dst, struct ip_tunnel *tunnel) |
625 | { | 626 | { |
626 | __be32 dst = 0; | 627 | __be32 dst = 0; |
627 | 628 | ||
@@ -664,8 +665,8 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, | |||
664 | { | 665 | { |
665 | struct ip_tunnel *tunnel = netdev_priv(dev); | 666 | struct ip_tunnel *tunnel = netdev_priv(dev); |
666 | struct pcpu_tstats *tstats; | 667 | struct pcpu_tstats *tstats; |
667 | struct iphdr *tiph = &tunnel->parms.iph; | 668 | const struct iphdr *tiph = &tunnel->parms.iph; |
668 | struct ipv6hdr *iph6 = ipv6_hdr(skb); | 669 | const struct ipv6hdr *iph6 = ipv6_hdr(skb); |
669 | u8 tos = tunnel->parms.iph.tos; | 670 | u8 tos = tunnel->parms.iph.tos; |
670 | __be16 df = tiph->frag_off; | 671 | __be16 df = tiph->frag_off; |
671 | struct rtable *rt; /* Route to the other host */ | 672 | struct rtable *rt; /* Route to the other host */ |
@@ -674,7 +675,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, | |||
674 | unsigned int max_headroom; /* The extra header space needed */ | 675 | unsigned int max_headroom; /* The extra header space needed */ |
675 | __be32 dst = tiph->daddr; | 676 | __be32 dst = tiph->daddr; |
676 | int mtu; | 677 | int mtu; |
677 | struct in6_addr *addr6; | 678 | const struct in6_addr *addr6; |
678 | int addr_type; | 679 | int addr_type; |
679 | 680 | ||
680 | if (skb->protocol != htons(ETH_P_IPV6)) | 681 | if (skb->protocol != htons(ETH_P_IPV6)) |
@@ -693,7 +694,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, | |||
693 | goto tx_error; | 694 | goto tx_error; |
694 | } | 695 | } |
695 | 696 | ||
696 | addr6 = (struct in6_addr*)&neigh->primary_key; | 697 | addr6 = (const struct in6_addr*)&neigh->primary_key; |
697 | addr_type = ipv6_addr_type(addr6); | 698 | addr_type = ipv6_addr_type(addr6); |
698 | 699 | ||
699 | if ((addr_type & IPV6_ADDR_UNICAST) && | 700 | if ((addr_type & IPV6_ADDR_UNICAST) && |
@@ -718,7 +719,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, | |||
718 | goto tx_error; | 719 | goto tx_error; |
719 | } | 720 | } |
720 | 721 | ||
721 | addr6 = (struct in6_addr*)&neigh->primary_key; | 722 | addr6 = (const struct in6_addr*)&neigh->primary_key; |
722 | addr_type = ipv6_addr_type(addr6); | 723 | addr_type = ipv6_addr_type(addr6); |
723 | 724 | ||
724 | if (addr_type == IPV6_ADDR_ANY) { | 725 | if (addr_type == IPV6_ADDR_ANY) { |
@@ -849,7 +850,7 @@ static void ipip6_tunnel_bind_dev(struct net_device *dev) | |||
849 | { | 850 | { |
850 | struct net_device *tdev = NULL; | 851 | struct net_device *tdev = NULL; |
851 | struct ip_tunnel *tunnel; | 852 | struct ip_tunnel *tunnel; |
852 | struct iphdr *iph; | 853 | const struct iphdr *iph; |
853 | 854 | ||
854 | tunnel = netdev_priv(dev); | 855 | tunnel = netdev_priv(dev); |
855 | iph = &tunnel->parms.iph; | 856 | iph = &tunnel->parms.iph; |