Skip to content

Commit b71d1d4

Browse files
Eric Dumazetdavem330
authored andcommitted
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>
1 parent 5f8629c commit b71d1d4

64 files changed

Lines changed: 316 additions & 310 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎include/net/addrconf.h‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,16 @@ extern int addrconf_set_dstaddr(struct net *net,
6161
void __user *arg);
6262

6363
extern int ipv6_chk_addr(struct net *net,
64-
struct in6_addr *addr,
64+
const struct in6_addr *addr,
6565
struct net_device *dev,
6666
int strict);
6767

6868
#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
6969
extern int ipv6_chk_home_addr(struct net *net,
70-
struct in6_addr *addr);
70+
const struct in6_addr *addr);
7171
#endif
7272

73-
extern int ipv6_chk_prefix(struct in6_addr *addr,
73+
extern int ipv6_chk_prefix(const struct in6_addr *addr,
7474
struct net_device *dev);
7575

7676
extern struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net,
@@ -89,9 +89,9 @@ extern int ipv6_get_lladdr(struct net_device *dev,
8989
extern int ipv6_rcv_saddr_equal(const struct sock *sk,
9090
const struct sock *sk2);
9191
extern void addrconf_join_solict(struct net_device *dev,
92-
struct in6_addr *addr);
92+
const struct in6_addr *addr);
9393
extern void addrconf_leave_solict(struct inet6_dev *idev,
94-
struct in6_addr *addr);
94+
const struct in6_addr *addr);
9595

9696
static inline unsigned long addrconf_timeout_fixup(u32 timeout,
9797
unsigned unit)
@@ -158,15 +158,15 @@ extern void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len);
158158
/*
159159
* anycast prototypes (anycast.c)
160160
*/
161-
extern int ipv6_sock_ac_join(struct sock *sk,int ifindex,struct in6_addr *addr);
162-
extern int ipv6_sock_ac_drop(struct sock *sk,int ifindex,struct in6_addr *addr);
161+
extern int ipv6_sock_ac_join(struct sock *sk,int ifindex, const struct in6_addr *addr);
162+
extern int ipv6_sock_ac_drop(struct sock *sk,int ifindex, const struct in6_addr *addr);
163163
extern void ipv6_sock_ac_close(struct sock *sk);
164-
extern int inet6_ac_check(struct sock *sk, struct in6_addr *addr, int ifindex);
164+
extern int inet6_ac_check(struct sock *sk, const struct in6_addr *addr, int ifindex);
165165

166-
extern int ipv6_dev_ac_inc(struct net_device *dev, struct in6_addr *addr);
167-
extern int __ipv6_dev_ac_dec(struct inet6_dev *idev, struct in6_addr *addr);
166+
extern int ipv6_dev_ac_inc(struct net_device *dev, const struct in6_addr *addr);
167+
extern int __ipv6_dev_ac_dec(struct inet6_dev *idev, const struct in6_addr *addr);
168168
extern int ipv6_chk_acast_addr(struct net *net, struct net_device *dev,
169-
struct in6_addr *addr);
169+
const struct in6_addr *addr);
170170

171171

172172
/* Device notifier */

‎include/net/if_inet6.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ struct inet6_dev {
196196
struct rcu_head rcu;
197197
};
198198

199-
static inline void ipv6_eth_mc_map(struct in6_addr *addr, char *buf)
199+
static inline void ipv6_eth_mc_map(const struct in6_addr *addr, char *buf)
200200
{
201201
/*
202202
* +-------+-------+-------+-------+-------+-------+
@@ -210,7 +210,7 @@ static inline void ipv6_eth_mc_map(struct in6_addr *addr, char *buf)
210210
memcpy(buf + 2, &addr->s6_addr32[3], sizeof(__u32));
211211
}
212212

213-
static inline void ipv6_tr_mc_map(struct in6_addr *addr, char *buf)
213+
static inline void ipv6_tr_mc_map(const struct in6_addr *addr, char *buf)
214214
{
215215
/* All nodes FF01::1, FF02::1, FF02::1:FFxx:xxxx */
216216

‎include/net/inetpeer.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static inline struct inet_peer *inet_getpeer_v4(__be32 v4daddr, int create)
8080
return inet_getpeer(&daddr, create);
8181
}
8282

83-
static inline struct inet_peer *inet_getpeer_v6(struct in6_addr *v6daddr, int create)
83+
static inline struct inet_peer *inet_getpeer_v6(const struct in6_addr *v6daddr, int create)
8484
{
8585
struct inetpeer_addr daddr;
8686

‎include/net/ip6_fib.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,12 @@ extern struct dst_entry *fib6_rule_lookup(struct net *net,
198198
pol_lookup_t lookup);
199199

200200
extern struct fib6_node *fib6_lookup(struct fib6_node *root,
201-
struct in6_addr *daddr,
202-
struct in6_addr *saddr);
201+
const struct in6_addr *daddr,
202+
const struct in6_addr *saddr);
203203

204204
struct fib6_node *fib6_locate(struct fib6_node *root,
205-
struct in6_addr *daddr, int dst_len,
206-
struct in6_addr *saddr, int src_len);
205+
const struct in6_addr *daddr, int dst_len,
206+
const struct in6_addr *saddr, int src_len);
207207

208208
extern void fib6_clean_all(struct net *net,
209209
int (*func)(struct rt6_info *, void *arg),

‎include/net/ip6_route.h‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ extern int ip6_del_rt(struct rt6_info *);
8686

8787
extern int ip6_route_get_saddr(struct net *net,
8888
struct rt6_info *rt,
89-
struct in6_addr *daddr,
89+
const struct in6_addr *daddr,
9090
unsigned int prefs,
9191
struct in6_addr *saddr);
9292

@@ -112,27 +112,27 @@ extern int ip6_dst_hoplimit(struct dst_entry *dst);
112112
* support functions for ND
113113
*
114114
*/
115-
extern struct rt6_info * rt6_get_dflt_router(struct in6_addr *addr,
115+
extern struct rt6_info * rt6_get_dflt_router(const struct in6_addr *addr,
116116
struct net_device *dev);
117-
extern struct rt6_info * rt6_add_dflt_router(struct in6_addr *gwaddr,
117+
extern struct rt6_info * rt6_add_dflt_router(const struct in6_addr *gwaddr,
118118
struct net_device *dev,
119119
unsigned int pref);
120120

121121
extern void rt6_purge_dflt_routers(struct net *net);
122122

123123
extern int rt6_route_rcv(struct net_device *dev,
124124
u8 *opt, int len,
125-
struct in6_addr *gwaddr);
125+
const struct in6_addr *gwaddr);
126126

127-
extern void rt6_redirect(struct in6_addr *dest,
128-
struct in6_addr *src,
129-
struct in6_addr *saddr,
127+
extern void rt6_redirect(const struct in6_addr *dest,
128+
const struct in6_addr *src,
129+
const struct in6_addr *saddr,
130130
struct neighbour *neigh,
131131
u8 *lladdr,
132132
int on_link);
133133

134-
extern void rt6_pmtu_discovery(struct in6_addr *daddr,
135-
struct in6_addr *saddr,
134+
extern void rt6_pmtu_discovery(const struct in6_addr *daddr,
135+
const struct in6_addr *saddr,
136136
struct net_device *dev,
137137
u32 pmtu);
138138

‎include/net/ipv6.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,8 @@ enum ip6_defrag_users {
376376
struct ip6_create_arg {
377377
__be32 id;
378378
u32 user;
379-
struct in6_addr *src;
380-
struct in6_addr *dst;
379+
const struct in6_addr *src;
380+
const struct in6_addr *dst;
381381
};
382382

383383
void ip6_frag_init(struct inet_frag_queue *q, void *a);

‎include/net/ndisc.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ extern void ndisc_send_redirect(struct sk_buff *skb,
102102
struct neighbour *neigh,
103103
const struct in6_addr *target);
104104

105-
extern int ndisc_mc_map(struct in6_addr *addr, char *buf, struct net_device *dev, int dir);
105+
extern int ndisc_mc_map(const struct in6_addr *addr, char *buf,
106+
struct net_device *dev, int dir);
106107

107108
extern struct sk_buff *ndisc_build_skb(struct net_device *dev,
108109
const struct in6_addr *daddr,

‎include/net/route.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ static inline int ip_route_input_noref(struct sk_buff *skb, __be32 dst, __be32 s
191191
return ip_route_input_common(skb, dst, src, tos, devin, true);
192192
}
193193

194-
extern unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph, unsigned short new_mtu, struct net_device *dev);
194+
extern unsigned short ip_rt_frag_needed(struct net *net, const struct iphdr *iph,
195+
unsigned short new_mtu, struct net_device *dev);
195196
extern void ip_rt_send_redirect(struct sk_buff *skb);
196197

197198
extern unsigned inet_addr_type(struct net *net, __be32 addr);

‎include/net/xfrm.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,7 @@ extern int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr,
14751475
extern int xfrm6_tunnel_register(struct xfrm6_tunnel *handler, unsigned short family);
14761476
extern int xfrm6_tunnel_deregister(struct xfrm6_tunnel *handler, unsigned short family);
14771477
extern __be32 xfrm6_tunnel_alloc_spi(struct net *net, xfrm_address_t *saddr);
1478-
extern __be32 xfrm6_tunnel_spi_lookup(struct net *net, xfrm_address_t *saddr);
1478+
extern __be32 xfrm6_tunnel_spi_lookup(struct net *net, const xfrm_address_t *saddr);
14791479
extern int xfrm6_extract_output(struct xfrm_state *x, struct sk_buff *skb);
14801480
extern int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb);
14811481
extern int xfrm6_output(struct sk_buff *skb);
@@ -1569,8 +1569,8 @@ static inline int xfrm_addr_cmp(const xfrm_address_t *a,
15691569
case AF_INET:
15701570
return (__force u32)a->a4 - (__force u32)b->a4;
15711571
case AF_INET6:
1572-
return ipv6_addr_cmp((struct in6_addr *)a,
1573-
(struct in6_addr *)b);
1572+
return ipv6_addr_cmp((const struct in6_addr *)a,
1573+
(const struct in6_addr *)b);
15741574
}
15751575
}
15761576

‎net/bridge/br_multicast.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ static struct sk_buff *br_ip4_multicast_alloc_query(struct net_bridge *br,
413413

414414
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
415415
static struct sk_buff *br_ip6_multicast_alloc_query(struct net_bridge *br,
416-
struct in6_addr *group)
416+
const struct in6_addr *group)
417417
{
418418
struct sk_buff *skb;
419419
struct ipv6hdr *ip6h;
@@ -1115,7 +1115,7 @@ static int br_ip4_multicast_query(struct net_bridge *br,
11151115
struct net_bridge_port *port,
11161116
struct sk_buff *skb)
11171117
{
1118-
struct iphdr *iph = ip_hdr(skb);
1118+
const struct iphdr *iph = ip_hdr(skb);
11191119
struct igmphdr *ih = igmp_hdr(skb);
11201120
struct net_bridge_mdb_entry *mp;
11211121
struct igmpv3_query *ih3;
@@ -1190,15 +1190,15 @@ static int br_ip6_multicast_query(struct net_bridge *br,
11901190
struct net_bridge_port *port,
11911191
struct sk_buff *skb)
11921192
{
1193-
struct ipv6hdr *ip6h = ipv6_hdr(skb);
1193+
const struct ipv6hdr *ip6h = ipv6_hdr(skb);
11941194
struct mld_msg *mld = (struct mld_msg *) icmp6_hdr(skb);
11951195
struct net_bridge_mdb_entry *mp;
11961196
struct mld2_query *mld2q;
11971197
struct net_bridge_port_group *p;
11981198
struct net_bridge_port_group __rcu **pp;
11991199
unsigned long max_delay;
12001200
unsigned long now = jiffies;
1201-
struct in6_addr *group = NULL;
1201+
const struct in6_addr *group = NULL;
12021202
int err = 0;
12031203

12041204
spin_lock(&br->multicast_lock);
@@ -1356,7 +1356,7 @@ static int br_multicast_ipv4_rcv(struct net_bridge *br,
13561356
struct sk_buff *skb)
13571357
{
13581358
struct sk_buff *skb2 = skb;
1359-
struct iphdr *iph;
1359+
const struct iphdr *iph;
13601360
struct igmphdr *ih;
13611361
unsigned len;
13621362
unsigned offset;
@@ -1452,7 +1452,7 @@ static int br_multicast_ipv6_rcv(struct net_bridge *br,
14521452
struct sk_buff *skb)
14531453
{
14541454
struct sk_buff *skb2;
1455-
struct ipv6hdr *ip6h;
1455+
const struct ipv6hdr *ip6h;
14561456
struct icmp6hdr *icmp6h;
14571457
u8 nexthdr;
14581458
unsigned len;

0 commit comments

Comments
 (0)