aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ip_gre.c
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2011-04-22 00:53:02 -0400
committerDavid S. Miller <davem@davemloft.net>2011-04-22 14:04:14 -0400
commitb71d1d426d263b0b6cb5760322efebbfc89d4463 (patch)
tree226ca7390bd6187ec9139d2ccedd26fd94d8e57a /net/ipv4/ip_gre.c
parent5f8629c526b4f7e529a6d27bbd802c0dc7fcc357 (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/ipv4/ip_gre.c')
-rw-r--r--net/ipv4/ip_gre.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index da5941f18c3c..24efd353279a 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -462,7 +462,7 @@ static void ipgre_err(struct sk_buff *skb, u32 info)
462 by themself??? 462 by themself???
463 */ 463 */
464 464
465 struct iphdr *iph = (struct iphdr *)skb->data; 465 const struct iphdr *iph = (const struct iphdr *)skb->data;
466 __be16 *p = (__be16*)(skb->data+(iph->ihl<<2)); 466 __be16 *p = (__be16*)(skb->data+(iph->ihl<<2));
467 int grehlen = (iph->ihl<<2) + 4; 467 int grehlen = (iph->ihl<<2) + 4;
468 const int type = icmp_hdr(skb)->type; 468 const int type = icmp_hdr(skb)->type;
@@ -534,7 +534,7 @@ out:
534 rcu_read_unlock(); 534 rcu_read_unlock();
535} 535}
536 536
537static inline void ipgre_ecn_decapsulate(struct iphdr *iph, struct sk_buff *skb) 537static inline void ipgre_ecn_decapsulate(const struct iphdr *iph, struct sk_buff *skb)
538{ 538{
539 if (INET_ECN_is_ce(iph->tos)) { 539 if (INET_ECN_is_ce(iph->tos)) {
540 if (skb->protocol == htons(ETH_P_IP)) { 540 if (skb->protocol == htons(ETH_P_IP)) {
@@ -546,19 +546,19 @@ static inline void ipgre_ecn_decapsulate(struct iphdr *iph, struct sk_buff *skb)
546} 546}
547 547
548static inline u8 548static inline u8
549ipgre_ecn_encapsulate(u8 tos, struct iphdr *old_iph, struct sk_buff *skb) 549ipgre_ecn_encapsulate(u8 tos, const struct iphdr *old_iph, struct sk_buff *skb)
550{ 550{
551 u8 inner = 0; 551 u8 inner = 0;
552 if (skb->protocol == htons(ETH_P_IP)) 552 if (skb->protocol == htons(ETH_P_IP))
553 inner = old_iph->tos; 553 inner = old_iph->tos;
554 else if (skb->protocol == htons(ETH_P_IPV6)) 554 else if (skb->protocol == htons(ETH_P_IPV6))
555 inner = ipv6_get_dsfield((struct ipv6hdr *)old_iph); 555 inner = ipv6_get_dsfield((const struct ipv6hdr *)old_iph);
556 return INET_ECN_encapsulate(tos, inner); 556 return INET_ECN_encapsulate(tos, inner);
557} 557}
558 558
559static int ipgre_rcv(struct sk_buff *skb) 559static int ipgre_rcv(struct sk_buff *skb)
560{ 560{
561 struct iphdr *iph; 561 const struct iphdr *iph;
562 u8 *h; 562 u8 *h;
563 __be16 flags; 563 __be16 flags;
564 __sum16 csum = 0; 564 __sum16 csum = 0;
@@ -697,8 +697,8 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
697{ 697{
698 struct ip_tunnel *tunnel = netdev_priv(dev); 698 struct ip_tunnel *tunnel = netdev_priv(dev);
699 struct pcpu_tstats *tstats; 699 struct pcpu_tstats *tstats;
700 struct iphdr *old_iph = ip_hdr(skb); 700 const struct iphdr *old_iph = ip_hdr(skb);
701 struct iphdr *tiph; 701 const struct iphdr *tiph;
702 u8 tos; 702 u8 tos;
703 __be16 df; 703 __be16 df;
704 struct rtable *rt; /* Route to the other host */ 704 struct rtable *rt; /* Route to the other host */
@@ -714,7 +714,7 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
714 714
715 if (dev->header_ops && dev->type == ARPHRD_IPGRE) { 715 if (dev->header_ops && dev->type == ARPHRD_IPGRE) {
716 gre_hlen = 0; 716 gre_hlen = 0;
717 tiph = (struct iphdr *)skb->data; 717 tiph = (const struct iphdr *)skb->data;
718 } else { 718 } else {
719 gre_hlen = tunnel->hlen; 719 gre_hlen = tunnel->hlen;
720 tiph = &tunnel->parms.iph; 720 tiph = &tunnel->parms.iph;
@@ -735,14 +735,14 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
735 } 735 }
736#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 736#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
737 else if (skb->protocol == htons(ETH_P_IPV6)) { 737 else if (skb->protocol == htons(ETH_P_IPV6)) {
738 struct in6_addr *addr6; 738 const struct in6_addr *addr6;
739 int addr_type; 739 int addr_type;
740 struct neighbour *neigh = skb_dst(skb)->neighbour; 740 struct neighbour *neigh = skb_dst(skb)->neighbour;
741 741
742 if (neigh == NULL) 742 if (neigh == NULL)
743 goto tx_error; 743 goto tx_error;
744 744
745 addr6 = (struct in6_addr *)&neigh->primary_key; 745 addr6 = (const struct in6_addr *)&neigh->primary_key;
746 addr_type = ipv6_addr_type(addr6); 746 addr_type = ipv6_addr_type(addr6);
747 747
748 if (addr_type == IPV6_ADDR_ANY) { 748 if (addr_type == IPV6_ADDR_ANY) {
@@ -766,7 +766,7 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
766 if (skb->protocol == htons(ETH_P_IP)) 766 if (skb->protocol == htons(ETH_P_IP))
767 tos = old_iph->tos; 767 tos = old_iph->tos;
768 else if (skb->protocol == htons(ETH_P_IPV6)) 768 else if (skb->protocol == htons(ETH_P_IPV6))
769 tos = ipv6_get_dsfield((struct ipv6hdr *)old_iph); 769 tos = ipv6_get_dsfield((const struct ipv6hdr *)old_iph);
770 } 770 }
771 771
772 rt = ip_route_output_gre(dev_net(dev), dst, tiph->saddr, 772 rt = ip_route_output_gre(dev_net(dev), dst, tiph->saddr,
@@ -881,7 +881,7 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
881 iph->ttl = old_iph->ttl; 881 iph->ttl = old_iph->ttl;
882#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 882#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
883 else if (skb->protocol == htons(ETH_P_IPV6)) 883 else if (skb->protocol == htons(ETH_P_IPV6))
884 iph->ttl = ((struct ipv6hdr *)old_iph)->hop_limit; 884 iph->ttl = ((const struct ipv6hdr *)old_iph)->hop_limit;
885#endif 885#endif
886 else 886 else
887 iph->ttl = ip4_dst_hoplimit(&rt->dst); 887 iph->ttl = ip4_dst_hoplimit(&rt->dst);
@@ -927,7 +927,7 @@ static int ipgre_tunnel_bind_dev(struct net_device *dev)
927{ 927{
928 struct net_device *tdev = NULL; 928 struct net_device *tdev = NULL;
929 struct ip_tunnel *tunnel; 929 struct ip_tunnel *tunnel;
930 struct iphdr *iph; 930 const struct iphdr *iph;
931 int hlen = LL_MAX_HEADER; 931 int hlen = LL_MAX_HEADER;
932 int mtu = ETH_DATA_LEN; 932 int mtu = ETH_DATA_LEN;
933 int addend = sizeof(struct iphdr) + 4; 933 int addend = sizeof(struct iphdr) + 4;
@@ -1180,7 +1180,7 @@ static int ipgre_header(struct sk_buff *skb, struct net_device *dev,
1180 1180
1181static int ipgre_header_parse(const struct sk_buff *skb, unsigned char *haddr) 1181static int ipgre_header_parse(const struct sk_buff *skb, unsigned char *haddr)
1182{ 1182{
1183 struct iphdr *iph = (struct iphdr *) skb_mac_header(skb); 1183 const struct iphdr *iph = (const struct iphdr *) skb_mac_header(skb);
1184 memcpy(haddr, &iph->saddr, 4); 1184 memcpy(haddr, &iph->saddr, 4);
1185 return 4; 1185 return 4;
1186} 1186}