Skip to content

Commit abfdf1c

Browse files
Jan Engelhardtdavem330
authored andcommitted
[NETFILTER]: ebtables: remove casts, use consts
Signed-off-by: Jan Engelhardt <jengelh@computergmbh.de> Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 000e8a5 commit abfdf1c

18 files changed

Lines changed: 95 additions & 70 deletions

‎include/net/arp.h‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ extern int arp_find(unsigned char *haddr, struct sk_buff *skb);
1313
extern int arp_ioctl(struct net *net, unsigned int cmd, void __user *arg);
1414
extern void arp_send(int type, int ptype, __be32 dest_ip,
1515
struct net_device *dev, __be32 src_ip,
16-
unsigned char *dest_hw, unsigned char *src_hw, unsigned char *th);
16+
const unsigned char *dest_hw,
17+
const unsigned char *src_hw, const unsigned char *th);
1718
extern int arp_bind_neighbour(struct dst_entry *dst);
1819
extern int arp_mc_map(__be32 addr, u8 *haddr, struct net_device *dev, int dir);
1920
extern void arp_ifdown(struct net_device *dev);
2021

2122
extern struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip,
2223
struct net_device *dev, __be32 src_ip,
23-
unsigned char *dest_hw, unsigned char *src_hw,
24-
unsigned char *target_hw);
24+
const unsigned char *dest_hw,
25+
const unsigned char *src_hw,
26+
const unsigned char *target_hw);
2527
extern void arp_xmit(struct sk_buff *skb);
2628

2729
extern struct neigh_ops arp_broken_ops;

‎net/bridge/netfilter/ebt_802_3.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
static int ebt_filter_802_3(const struct sk_buff *skb, const struct net_device *in,
1616
const struct net_device *out, const void *data, unsigned int datalen)
1717
{
18-
struct ebt_802_3_info *info = (struct ebt_802_3_info *)data;
19-
struct ebt_802_3_hdr *hdr = ebt_802_3_hdr(skb);
18+
const struct ebt_802_3_info *info = data;
19+
const struct ebt_802_3_hdr *hdr = ebt_802_3_hdr(skb);
2020
__be16 type = hdr->llc.ui.ctrl & IS_UI ? hdr->llc.ui.type : hdr->llc.ni.type;
2121

2222
if (info->bitmask & EBT_802_3_SAP) {
@@ -40,7 +40,7 @@ static struct ebt_match filter_802_3;
4040
static int ebt_802_3_check(const char *tablename, unsigned int hookmask,
4141
const struct ebt_entry *e, void *data, unsigned int datalen)
4242
{
43-
struct ebt_802_3_info *info = (struct ebt_802_3_info *)data;
43+
const struct ebt_802_3_info *info = data;
4444

4545
if (datalen < sizeof(struct ebt_802_3_info))
4646
return -EINVAL;

‎net/bridge/netfilter/ebt_among.c‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static int ebt_mac_wormhash_contains(const struct ebt_mac_wormhash *wh,
2525
const struct ebt_mac_wormhash_tuple *p;
2626
int start, limit, i;
2727
uint32_t cmp[2] = { 0, 0 };
28-
int key = (const unsigned char) mac[5];
28+
int key = ((const unsigned char *)mac)[5];
2929

3030
memcpy(((char *) cmp) + 2, mac, 6);
3131
start = wh->table[key];
@@ -73,15 +73,18 @@ static int ebt_mac_wormhash_check_integrity(const struct ebt_mac_wormhash
7373
static int get_ip_dst(const struct sk_buff *skb, __be32 *addr)
7474
{
7575
if (eth_hdr(skb)->h_proto == htons(ETH_P_IP)) {
76-
struct iphdr _iph, *ih;
76+
const struct iphdr *ih;
77+
struct iphdr _iph;
7778

7879
ih = skb_header_pointer(skb, 0, sizeof(_iph), &_iph);
7980
if (ih == NULL)
8081
return -1;
8182
*addr = ih->daddr;
8283
} else if (eth_hdr(skb)->h_proto == htons(ETH_P_ARP)) {
83-
struct arphdr _arph, *ah;
84-
__be32 buf, *bp;
84+
const struct arphdr *ah;
85+
struct arphdr _arph;
86+
const __be32 *bp;
87+
__be32 buf;
8588

8689
ah = skb_header_pointer(skb, 0, sizeof(_arph), &_arph);
8790
if (ah == NULL ||
@@ -101,15 +104,18 @@ static int get_ip_dst(const struct sk_buff *skb, __be32 *addr)
101104
static int get_ip_src(const struct sk_buff *skb, __be32 *addr)
102105
{
103106
if (eth_hdr(skb)->h_proto == htons(ETH_P_IP)) {
104-
struct iphdr _iph, *ih;
107+
const struct iphdr *ih;
108+
struct iphdr _iph;
105109

106110
ih = skb_header_pointer(skb, 0, sizeof(_iph), &_iph);
107111
if (ih == NULL)
108112
return -1;
109113
*addr = ih->saddr;
110114
} else if (eth_hdr(skb)->h_proto == htons(ETH_P_ARP)) {
111-
struct arphdr _arph, *ah;
112-
__be32 buf, *bp;
115+
const struct arphdr *ah;
116+
struct arphdr _arph;
117+
const __be32 *bp;
118+
__be32 buf;
113119

114120
ah = skb_header_pointer(skb, 0, sizeof(_arph), &_arph);
115121
if (ah == NULL ||
@@ -130,7 +136,7 @@ static int ebt_filter_among(const struct sk_buff *skb,
130136
const struct net_device *out, const void *data,
131137
unsigned int datalen)
132138
{
133-
struct ebt_among_info *info = (struct ebt_among_info *) data;
139+
const struct ebt_among_info *info = data;
134140
const char *dmac, *smac;
135141
const struct ebt_mac_wormhash *wh_dst, *wh_src;
136142
__be32 dip = 0, sip = 0;
@@ -175,7 +181,7 @@ static int ebt_among_check(const char *tablename, unsigned int hookmask,
175181
const struct ebt_entry *e, void *data,
176182
unsigned int datalen)
177183
{
178-
struct ebt_among_info *info = (struct ebt_among_info *) data;
184+
const struct ebt_among_info *info = data;
179185
int expected_length = sizeof(struct ebt_among_info);
180186
const struct ebt_mac_wormhash *wh_dst, *wh_src;
181187
int err;

‎net/bridge/netfilter/ebt_arp.c‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
static int ebt_filter_arp(const struct sk_buff *skb, const struct net_device *in,
1919
const struct net_device *out, const void *data, unsigned int datalen)
2020
{
21-
struct ebt_arp_info *info = (struct ebt_arp_info *)data;
22-
struct arphdr _arph, *ah;
21+
const struct ebt_arp_info *info = data;
22+
const struct arphdr *ah;
23+
struct arphdr _arph;
2324

2425
ah = skb_header_pointer(skb, 0, sizeof(_arph), &_arph);
2526
if (ah == NULL)
@@ -35,7 +36,8 @@ static int ebt_filter_arp(const struct sk_buff *skb, const struct net_device *in
3536
return EBT_NOMATCH;
3637

3738
if (info->bitmask & (EBT_ARP_SRC_IP | EBT_ARP_DST_IP | EBT_ARP_GRAT)) {
38-
__be32 saddr, daddr, *sap, *dap;
39+
const __be32 *sap, *dap;
40+
__be32 saddr, daddr;
3941

4042
if (ah->ar_pln != sizeof(__be32) || ah->ar_pro != htons(ETH_P_IP))
4143
return EBT_NOMATCH;
@@ -61,7 +63,8 @@ static int ebt_filter_arp(const struct sk_buff *skb, const struct net_device *in
6163
}
6264

6365
if (info->bitmask & (EBT_ARP_SRC_MAC | EBT_ARP_DST_MAC)) {
64-
unsigned char _mac[ETH_ALEN], *mp;
66+
const unsigned char *mp;
67+
unsigned char _mac[ETH_ALEN];
6568
uint8_t verdict, i;
6669

6770
if (ah->ar_hln != ETH_ALEN || ah->ar_hrd != htons(ARPHRD_ETHER))
@@ -100,7 +103,7 @@ static int ebt_filter_arp(const struct sk_buff *skb, const struct net_device *in
100103
static int ebt_arp_check(const char *tablename, unsigned int hookmask,
101104
const struct ebt_entry *e, void *data, unsigned int datalen)
102105
{
103-
struct ebt_arp_info *info = (struct ebt_arp_info *)data;
106+
const struct ebt_arp_info *info = data;
104107

105108
if (datalen != EBT_ALIGN(sizeof(struct ebt_arp_info)))
106109
return -EINVAL;

‎net/bridge/netfilter/ebt_arpreply.c‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ static int ebt_target_reply(struct sk_buff *skb, unsigned int hooknr,
1919
const struct net_device *in, const struct net_device *out,
2020
const void *data, unsigned int datalen)
2121
{
22-
struct ebt_arpreply_info *info = (struct ebt_arpreply_info *)data;
23-
__be32 _sip, *siptr, _dip, *diptr;
24-
struct arphdr _ah, *ap;
25-
unsigned char _sha[ETH_ALEN], *shp;
22+
struct ebt_arpreply_info *info = (void *)data;
23+
const __be32 *siptr, *diptr;
24+
__be32 _sip, _dip;
25+
const struct arphdr *ap;
26+
struct arphdr _ah;
27+
const unsigned char *shp;
28+
unsigned char _sha[ETH_ALEN];
2629

2730
ap = skb_header_pointer(skb, 0, sizeof(_ah), &_ah);
2831
if (ap == NULL)
@@ -58,7 +61,7 @@ static int ebt_target_reply(struct sk_buff *skb, unsigned int hooknr,
5861
static int ebt_target_reply_check(const char *tablename, unsigned int hookmask,
5962
const struct ebt_entry *e, void *data, unsigned int datalen)
6063
{
61-
struct ebt_arpreply_info *info = (struct ebt_arpreply_info *)data;
64+
const struct ebt_arpreply_info *info = data;
6265

6366
if (datalen != EBT_ALIGN(sizeof(struct ebt_arpreply_info)))
6467
return -EINVAL;

‎net/bridge/netfilter/ebt_dnat.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static int ebt_target_dnat(struct sk_buff *skb, unsigned int hooknr,
1818
const struct net_device *in, const struct net_device *out,
1919
const void *data, unsigned int datalen)
2020
{
21-
struct ebt_nat_info *info = (struct ebt_nat_info *)data;
21+
const struct ebt_nat_info *info = data;
2222

2323
if (skb_make_writable(skb, 0))
2424
return NF_DROP;
@@ -30,7 +30,7 @@ static int ebt_target_dnat(struct sk_buff *skb, unsigned int hooknr,
3030
static int ebt_target_dnat_check(const char *tablename, unsigned int hookmask,
3131
const struct ebt_entry *e, void *data, unsigned int datalen)
3232
{
33-
struct ebt_nat_info *info = (struct ebt_nat_info *)data;
33+
const struct ebt_nat_info *info = data;
3434

3535
if (BASE_CHAIN && info->target == EBT_RETURN)
3636
return -EINVAL;

‎net/bridge/netfilter/ebt_ip.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ static int ebt_filter_ip(const struct sk_buff *skb, const struct net_device *in,
2828
const struct net_device *out, const void *data,
2929
unsigned int datalen)
3030
{
31-
struct ebt_ip_info *info = (struct ebt_ip_info *)data;
32-
struct iphdr _iph, *ih;
33-
struct tcpudphdr _ports, *pptr;
31+
const struct ebt_ip_info *info = data;
32+
const struct iphdr *ih;
33+
struct iphdr _iph;
34+
const struct tcpudphdr *pptr;
35+
struct tcpudphdr _ports;
3436

3537
ih = skb_header_pointer(skb, 0, sizeof(_iph), &_iph);
3638
if (ih == NULL)
@@ -79,7 +81,7 @@ static int ebt_filter_ip(const struct sk_buff *skb, const struct net_device *in,
7981
static int ebt_ip_check(const char *tablename, unsigned int hookmask,
8082
const struct ebt_entry *e, void *data, unsigned int datalen)
8183
{
82-
struct ebt_ip_info *info = (struct ebt_ip_info *)data;
84+
const struct ebt_ip_info *info = data;
8385

8486
if (datalen != EBT_ALIGN(sizeof(struct ebt_ip_info)))
8587
return -EINVAL;

‎net/bridge/netfilter/ebt_limit.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ user2credits(u_int32_t user)
6969
static int ebt_limit_check(const char *tablename, unsigned int hookmask,
7070
const struct ebt_entry *e, void *data, unsigned int datalen)
7171
{
72-
struct ebt_limit_info *info = (struct ebt_limit_info *)data;
72+
struct ebt_limit_info *info = data;
7373

7474
if (datalen != EBT_ALIGN(sizeof(struct ebt_limit_info)))
7575
return -EINVAL;

‎net/bridge/netfilter/ebt_log.c‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ static DEFINE_SPINLOCK(ebt_log_lock);
2424
static int ebt_log_check(const char *tablename, unsigned int hookmask,
2525
const struct ebt_entry *e, void *data, unsigned int datalen)
2626
{
27-
struct ebt_log_info *info = (struct ebt_log_info *)data;
27+
struct ebt_log_info *info = data;
2828

2929
if (datalen != EBT_ALIGN(sizeof(struct ebt_log_info)))
3030
return -EINVAL;
@@ -50,7 +50,7 @@ struct arppayload
5050
unsigned char ip_dst[4];
5151
};
5252

53-
static void print_MAC(unsigned char *p)
53+
static void print_MAC(const unsigned char *p)
5454
{
5555
int i;
5656

@@ -84,7 +84,8 @@ ebt_log_packet(unsigned int pf, unsigned int hooknum,
8484

8585
if ((bitmask & EBT_LOG_IP) && eth_hdr(skb)->h_proto ==
8686
htons(ETH_P_IP)){
87-
struct iphdr _iph, *ih;
87+
const struct iphdr *ih;
88+
struct iphdr _iph;
8889

8990
ih = skb_header_pointer(skb, 0, sizeof(_iph), &_iph);
9091
if (ih == NULL) {
@@ -99,7 +100,8 @@ ebt_log_packet(unsigned int pf, unsigned int hooknum,
99100
ih->protocol == IPPROTO_UDPLITE ||
100101
ih->protocol == IPPROTO_SCTP ||
101102
ih->protocol == IPPROTO_DCCP) {
102-
struct tcpudphdr _ports, *pptr;
103+
const struct tcpudphdr *pptr;
104+
struct tcpudphdr _ports;
103105

104106
pptr = skb_header_pointer(skb, ih->ihl*4,
105107
sizeof(_ports), &_ports);
@@ -116,7 +118,8 @@ ebt_log_packet(unsigned int pf, unsigned int hooknum,
116118
if ((bitmask & EBT_LOG_ARP) &&
117119
((eth_hdr(skb)->h_proto == htons(ETH_P_ARP)) ||
118120
(eth_hdr(skb)->h_proto == htons(ETH_P_RARP)))) {
119-
struct arphdr _arph, *ah;
121+
const struct arphdr *ah;
122+
struct arphdr _arph;
120123

121124
ah = skb_header_pointer(skb, 0, sizeof(_arph), &_arph);
122125
if (ah == NULL) {
@@ -132,7 +135,8 @@ ebt_log_packet(unsigned int pf, unsigned int hooknum,
132135
if (ah->ar_hrd == htons(1) &&
133136
ah->ar_hln == ETH_ALEN &&
134137
ah->ar_pln == sizeof(__be32)) {
135-
struct arppayload _arpp, *ap;
138+
const struct arppayload *ap;
139+
struct arppayload _arpp;
136140

137141
ap = skb_header_pointer(skb, sizeof(_arph),
138142
sizeof(_arpp), &_arpp);
@@ -160,7 +164,7 @@ static void ebt_log(const struct sk_buff *skb, unsigned int hooknr,
160164
const struct net_device *in, const struct net_device *out,
161165
const void *data, unsigned int datalen)
162166
{
163-
struct ebt_log_info *info = (struct ebt_log_info *)data;
167+
const struct ebt_log_info *info = data;
164168
struct nf_loginfo li;
165169

166170
li.type = NF_LOG_TYPE_LOG;

‎net/bridge/netfilter/ebt_mark.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static int ebt_target_mark(struct sk_buff *skb, unsigned int hooknr,
2121
const struct net_device *in, const struct net_device *out,
2222
const void *data, unsigned int datalen)
2323
{
24-
struct ebt_mark_t_info *info = (struct ebt_mark_t_info *)data;
24+
const struct ebt_mark_t_info *info = data;
2525
int action = info->target & -16;
2626

2727
if (action == MARK_SET_VALUE)
@@ -39,7 +39,7 @@ static int ebt_target_mark(struct sk_buff *skb, unsigned int hooknr,
3939
static int ebt_target_mark_check(const char *tablename, unsigned int hookmask,
4040
const struct ebt_entry *e, void *data, unsigned int datalen)
4141
{
42-
struct ebt_mark_t_info *info = (struct ebt_mark_t_info *)data;
42+
const struct ebt_mark_t_info *info = data;
4343
int tmp;
4444

4545
if (datalen != EBT_ALIGN(sizeof(struct ebt_mark_t_info)))

0 commit comments

Comments
 (0)