Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a47362a2 authored by Jan Engelhardt's avatar Jan Engelhardt Committed by David S. Miller
Browse files

[NETFILTER]: add some consts, remove some casts



Make a number of variables const and/or remove unneeded casts.

Signed-off-by: default avatarJan Engelhardt <jengelh@gmx.de>
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e1931b78
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -235,12 +235,13 @@ clusterip_del_node(struct clusterip_config *c, u_int16_t nodenum)
#endif

static inline u_int32_t
clusterip_hashfn(struct sk_buff *skb, struct clusterip_config *config)
clusterip_hashfn(const struct sk_buff *skb,
		 const struct clusterip_config *config)
{
	struct iphdr *iph = ip_hdr(skb);
	const struct iphdr *iph = ip_hdr(skb);
	unsigned long hashval;
	u_int16_t sport, dport;
	u_int16_t *ports;
	const u_int16_t *ports;

	switch (iph->protocol) {
	case IPPROTO_TCP:
@@ -249,7 +250,7 @@ clusterip_hashfn(struct sk_buff *skb, struct clusterip_config *config)
	case IPPROTO_SCTP:
	case IPPROTO_DCCP:
	case IPPROTO_ICMP:
		ports = (void *)iph+iph->ihl*4;
		ports = (const void *)iph+iph->ihl*4;
		sport = ports[0];
		dport = ports[1];
		break;
@@ -289,7 +290,7 @@ clusterip_hashfn(struct sk_buff *skb, struct clusterip_config *config)
}

static inline int
clusterip_responsible(struct clusterip_config *config, u_int32_t hash)
clusterip_responsible(const struct clusterip_config *config, u_int32_t hash)
{
	return test_bit(hash - 1, &config->local_nodes);
}
+17 −9
Original line number Diff line number Diff line
@@ -41,7 +41,8 @@ static void dump_packet(const struct nf_loginfo *info,
			const struct sk_buff *skb,
			unsigned int iphoff)
{
	struct iphdr _iph, *ih;
	struct iphdr _iph;
	const struct iphdr *ih;
	unsigned int logflags;

	if (info->type == NF_LOG_TYPE_LOG)
@@ -100,7 +101,8 @@ static void dump_packet(const struct nf_loginfo *info,

	switch (ih->protocol) {
	case IPPROTO_TCP: {
		struct tcphdr _tcph, *th;
		struct tcphdr _tcph;
		const struct tcphdr *th;

		/* Max length: 10 "PROTO=TCP " */
		printk("PROTO=TCP ");
@@ -151,7 +153,7 @@ static void dump_packet(const struct nf_loginfo *info,
		if ((logflags & IPT_LOG_TCPOPT)
		    && th->doff * 4 > sizeof(struct tcphdr)) {
			unsigned char _opt[4 * 15 - sizeof(struct tcphdr)];
			unsigned char *op;
			const unsigned char *op;
			unsigned int i, optsize;

			optsize = th->doff * 4 - sizeof(struct tcphdr);
@@ -173,7 +175,8 @@ static void dump_packet(const struct nf_loginfo *info,
	}
	case IPPROTO_UDP:
	case IPPROTO_UDPLITE: {
		struct udphdr _udph, *uh;
		struct udphdr _udph;
		const struct udphdr *uh;

		if (ih->protocol == IPPROTO_UDP)
			/* Max length: 10 "PROTO=UDP "     */
@@ -200,7 +203,8 @@ static void dump_packet(const struct nf_loginfo *info,
		break;
	}
	case IPPROTO_ICMP: {
		struct icmphdr _icmph, *ich;
		struct icmphdr _icmph;
		const struct icmphdr *ich;
		static const size_t required_len[NR_ICMP_TYPES+1]
			= { [ICMP_ECHOREPLY] = 4,
			    [ICMP_DEST_UNREACH]
@@ -285,7 +289,8 @@ static void dump_packet(const struct nf_loginfo *info,
	}
	/* Max Length */
	case IPPROTO_AH: {
		struct ip_auth_hdr _ahdr, *ah;
		struct ip_auth_hdr _ahdr;
		const struct ip_auth_hdr *ah;

		if (ntohs(ih->frag_off) & IP_OFFSET)
			break;
@@ -307,7 +312,8 @@ static void dump_packet(const struct nf_loginfo *info,
		break;
	}
	case IPPROTO_ESP: {
		struct ip_esp_hdr _esph, *eh;
		struct ip_esp_hdr _esph;
		const struct ip_esp_hdr *eh;

		/* Max length: 10 "PROTO=ESP " */
		printk("PROTO=ESP ");
@@ -385,11 +391,13 @@ ipt_log_packet(unsigned int pf,
	       out ? out->name : "");
#ifdef CONFIG_BRIDGE_NETFILTER
	if (skb->nf_bridge) {
		struct net_device *physindev = skb->nf_bridge->physindev;
		struct net_device *physoutdev = skb->nf_bridge->physoutdev;
		const struct net_device *physindev;
		const struct net_device *physoutdev;

		physindev = skb->nf_bridge->physindev;
		if (physindev && in != physindev)
			printk("PHYSIN=%s ", physindev->name);
		physoutdev = skb->nf_bridge->physoutdev;
		if (physoutdev && out != physoutdev)
			printk("PHYSOUT=%s ", physoutdev->name);
	}
+4 −4
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ masquerade_target(struct sk_buff **pskb,
	enum ip_conntrack_info ctinfo;
	struct nf_nat_range newrange;
	const struct nf_nat_multi_range_compat *mr;
	struct rtable *rt;
	const struct rtable *rt;
	__be32 newsrc;

	NF_CT_ASSERT(hooknum == NF_IP_POST_ROUTING);
@@ -112,7 +112,7 @@ masquerade_target(struct sk_buff **pskb,
static inline int
device_cmp(struct nf_conn *i, void *ifindex)
{
	struct nf_conn_nat *nat = nfct_nat(i);
	const struct nf_conn_nat *nat = nfct_nat(i);
	int ret;

	if (!nat)
@@ -129,7 +129,7 @@ static int masq_device_event(struct notifier_block *this,
			     unsigned long event,
			     void *ptr)
{
	struct net_device *dev = ptr;
	const struct net_device *dev = ptr;

	if (event == NETDEV_DOWN) {
		/* Device was downed.  Search entire table for
@@ -147,7 +147,7 @@ static int masq_inet_event(struct notifier_block *this,
			   unsigned long event,
			   void *ptr)
{
	struct net_device *dev = ((struct in_ifaddr *)ptr)->ifa_dev->dev;
	const struct net_device *dev = ((struct in_ifaddr *)ptr)->ifa_dev->dev;

	if (event == NETDEV_DOWN) {
		/* IP address was deleted.  Search entire table for
+1 −1
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ static void send_reset(struct sk_buff *oldskb, int hook)
	tcph->check = 0;
	tcph->check = tcp_v4_check(sizeof(struct tcphdr),
				   niph->saddr, niph->daddr,
				   csum_partial((char *)tcph,
				   csum_partial(tcph,
						sizeof(struct tcphdr), 0));

	/* Set DF, id = 0 */
+1 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ static bool ipt_ttl_checkentry(const char *tablename,
		void *targinfo,
		unsigned int hook_mask)
{
	struct ipt_TTL_info *info = targinfo;
	const struct ipt_TTL_info *info = targinfo;

	if (info->mode > IPT_TTL_MAXMODE) {
		printk(KERN_WARNING "ipt_TTL: invalid or unknown Mode %u\n",
Loading