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

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

[NETFILTER]: x_tables: switch xt_target->checkentry to bool



Switch the return type of target checkentry functions to boolean.

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 ccb79bdc
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -202,7 +202,7 @@ struct xt_target
           hook_mask is a bitmask of hooks from which it can be
           called. */
	/* Should return true or false. */
	int (*checkentry)(const char *tablename,
	bool (*checkentry)(const char *tablename,
			   const void *entry,
			   const struct xt_target *target,
			   void *targinfo,
+4 −4
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ target(struct sk_buff **pskb,
	return mangle->target;
}

static int
static bool
checkentry(const char *tablename, const void *e, const struct xt_target *target,
	   void *targinfo, unsigned int hook_mask)
{
@@ -73,12 +73,12 @@ checkentry(const char *tablename, const void *e, const struct xt_target *target,

	if (mangle->flags & ~ARPT_MANGLE_MASK ||
	    !(mangle->flags & ARPT_MANGLE_MASK))
		return 0;
		return false;

	if (mangle->target != NF_DROP && mangle->target != NF_ACCEPT &&
	   mangle->target != ARPT_CONTINUE)
		return 0;
	return 1;
		return false;
	return true;
}

static struct arpt_target arpt_mangle_reg = {
+14 −14
Original line number Diff line number Diff line
@@ -220,17 +220,17 @@ clusterip_add_node(struct clusterip_config *c, u_int16_t nodenum)
	return 0;
}

static int
static bool
clusterip_del_node(struct clusterip_config *c, u_int16_t nodenum)
{
	if (nodenum == 0 ||
	    nodenum > c->num_total_nodes)
		return 1;
		return true;

	if (test_and_clear_bit(nodenum - 1, &c->local_nodes))
		return 0;
		return false;

	return 1;
	return true;
}
#endif

@@ -370,7 +370,7 @@ target(struct sk_buff **pskb,
	return XT_CONTINUE;
}

static int
static bool
checkentry(const char *tablename,
	   const void *e_void,
	   const struct xt_target *target,
@@ -387,13 +387,13 @@ checkentry(const char *tablename,
	    cipinfo->hash_mode != CLUSTERIP_HASHMODE_SIP_SPT_DPT) {
		printk(KERN_WARNING "CLUSTERIP: unknown mode `%u'\n",
			cipinfo->hash_mode);
		return 0;
		return false;

	}
	if (e->ip.dmsk.s_addr != htonl(0xffffffff)
	    || e->ip.dst.s_addr == 0) {
		printk(KERN_ERR "CLUSTERIP: Please specify destination IP\n");
		return 0;
		return false;
	}

	/* FIXME: further sanity checks */
@@ -407,7 +407,7 @@ checkentry(const char *tablename,
			if (cipinfo->config != config) {
				printk(KERN_ERR "CLUSTERIP: Reloaded entry "
				       "has invalid config pointer!\n");
				return 0;
				return false;
			}
		} else {
			/* Case B: This is a new rule referring to an existing
@@ -418,19 +418,19 @@ checkentry(const char *tablename,
		/* Case C: This is a completely new clusterip config */
		if (!(cipinfo->flags & CLUSTERIP_FLAG_NEW)) {
			printk(KERN_WARNING "CLUSTERIP: no config found for %u.%u.%u.%u, need 'new'\n", NIPQUAD(e->ip.dst.s_addr));
			return 0;
			return false;
		} else {
			struct net_device *dev;

			if (e->ip.iniface[0] == '\0') {
				printk(KERN_WARNING "CLUSTERIP: Please specify an interface name\n");
				return 0;
				return false;
			}

			dev = dev_get_by_name(e->ip.iniface);
			if (!dev) {
				printk(KERN_WARNING "CLUSTERIP: no such interface %s\n", e->ip.iniface);
				return 0;
				return false;
			}

			config = clusterip_config_init(cipinfo,
@@ -438,7 +438,7 @@ checkentry(const char *tablename,
			if (!config) {
				printk(KERN_WARNING "CLUSTERIP: cannot allocate config\n");
				dev_put(dev);
				return 0;
				return false;
			}
			dev_mc_add(config->dev,config->clustermac, ETH_ALEN, 0);
		}
@@ -448,10 +448,10 @@ checkentry(const char *tablename,
	if (nf_ct_l3proto_try_module_get(target->family) < 0) {
		printk(KERN_WARNING "can't load conntrack support for "
				    "proto=%d\n", target->family);
		return 0;
		return false;
	}

	return 1;
	return true;
}

/* drop reference count of cluster config when rule is deleted */
+15 −15
Original line number Diff line number Diff line
@@ -24,8 +24,8 @@ MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
MODULE_DESCRIPTION("iptables ECN modification module");

/* set ECT codepoint from IP header.
 * 	return 0 if there was an error. */
static inline int
 * 	return false if there was an error. */
static inline bool
set_ect_ip(struct sk_buff **pskb, const struct ipt_ECN_info *einfo)
{
	struct iphdr *iph = ip_hdr(*pskb);
@@ -33,18 +33,18 @@ set_ect_ip(struct sk_buff **pskb, const struct ipt_ECN_info *einfo)
	if ((iph->tos & IPT_ECN_IP_MASK) != (einfo->ip_ect & IPT_ECN_IP_MASK)) {
		__u8 oldtos;
		if (!skb_make_writable(pskb, sizeof(struct iphdr)))
			return 0;
			return false;
		iph = ip_hdr(*pskb);
		oldtos = iph->tos;
		iph->tos &= ~IPT_ECN_IP_MASK;
		iph->tos |= (einfo->ip_ect & IPT_ECN_IP_MASK);
		nf_csum_replace2(&iph->check, htons(oldtos), htons(iph->tos));
	}
	return 1;
	return true;
}

/* Return 0 if there was an error. */
static inline int
/* Return false if there was an error. */
static inline bool
set_ect_tcp(struct sk_buff **pskb, const struct ipt_ECN_info *einfo)
{
	struct tcphdr _tcph, *tcph;
@@ -54,16 +54,16 @@ set_ect_tcp(struct sk_buff **pskb, const struct ipt_ECN_info *einfo)
	tcph = skb_header_pointer(*pskb, ip_hdrlen(*pskb),
				  sizeof(_tcph), &_tcph);
	if (!tcph)
		return 0;
		return false;

	if ((!(einfo->operation & IPT_ECN_OP_SET_ECE) ||
	     tcph->ece == einfo->proto.tcp.ece) &&
	    ((!(einfo->operation & IPT_ECN_OP_SET_CWR) ||
	     tcph->cwr == einfo->proto.tcp.cwr)))
		return 1;
		return true;

	if (!skb_make_writable(pskb, ip_hdrlen(*pskb) + sizeof(*tcph)))
		return 0;
		return false;
	tcph = (void *)ip_hdr(*pskb) + ip_hdrlen(*pskb);

	oldval = ((__be16 *)tcph)[6];
@@ -74,7 +74,7 @@ set_ect_tcp(struct sk_buff **pskb, const struct ipt_ECN_info *einfo)

	nf_proto_csum_replace2(&tcph->check, *pskb,
				oldval, ((__be16 *)tcph)[6], 0);
	return 1;
	return true;
}

static unsigned int
@@ -99,7 +99,7 @@ target(struct sk_buff **pskb,
	return XT_CONTINUE;
}

static int
static bool
checkentry(const char *tablename,
	   const void *e_void,
	   const struct xt_target *target,
@@ -112,20 +112,20 @@ checkentry(const char *tablename,
	if (einfo->operation & IPT_ECN_OP_MASK) {
		printk(KERN_WARNING "ECN: unsupported ECN operation %x\n",
			einfo->operation);
		return 0;
		return false;
	}
	if (einfo->ip_ect & ~IPT_ECN_IP_MASK) {
		printk(KERN_WARNING "ECN: new ECT codepoint %x out of mask\n",
			einfo->ip_ect);
		return 0;
		return false;
	}
	if ((einfo->operation & (IPT_ECN_OP_SET_ECE|IPT_ECN_OP_SET_CWR))
	    && (e->ip.proto != IPPROTO_TCP || (e->ip.invflags & XT_INV_PROTO))) {
		printk(KERN_WARNING "ECN: cannot use TCP operations on a "
		       "non-tcp rule\n");
		return 0;
		return false;
	}
	return 1;
	return true;
}

static struct xt_target ipt_ecn_reg = {
+8 −8
Original line number Diff line number Diff line
@@ -435,7 +435,7 @@ ipt_log_target(struct sk_buff **pskb,
	return XT_CONTINUE;
}

static int ipt_log_checkentry(const char *tablename,
static bool ipt_log_checkentry(const char *tablename,
			       const void *e,
			       const struct xt_target *target,
			       void *targinfo,
@@ -445,14 +445,14 @@ static int ipt_log_checkentry(const char *tablename,

	if (loginfo->level >= 8) {
		DEBUGP("LOG: level %u >= 8\n", loginfo->level);
		return 0;
		return false;
	}
	if (loginfo->prefix[sizeof(loginfo->prefix)-1] != '\0') {
		DEBUGP("LOG: prefix term %i\n",
		       loginfo->prefix[sizeof(loginfo->prefix)-1]);
		return 0;
		return false;
	}
	return 1;
	return true;
}

static struct xt_target ipt_log_reg = {
Loading