Skip to content

Commit

Permalink
netfilter: xtables: change xt_match.checkentry return type
Browse files Browse the repository at this point in the history
Restore function signatures from bool to int so that we can report
memory allocation failures or similar using -ENOMEM rather than
always having to pass -EINVAL back.

This semantic patch may not be too precise (checking for functions
that use xt_mtchk_param rather than functions referenced by
xt_match.checkentry), but reviewed, it produced the intended result.

// <smpl>
@@
type bool;
identifier check, par;
@@
-bool check
+int check
 (struct xt_mtchk_param *par) { ... }
// </smpl>

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
  • Loading branch information
Jan Engelhardt committed Mar 25, 2010
1 parent 9f56731 commit b0f3845
Show file tree
Hide file tree
Showing 45 changed files with 50 additions and 50 deletions.
2 changes: 1 addition & 1 deletion include/linux/netfilter/x_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ struct xt_match {
const struct xt_match_param *);

/* Called when user tries to insert an entry of this type. */
bool (*checkentry)(const struct xt_mtchk_param *);
int (*checkentry)(const struct xt_mtchk_param *);

/* Called when entry of this type deleted. */
void (*destroy)(const struct xt_mtdtor_param *);
Expand Down
2 changes: 1 addition & 1 deletion net/bridge/netfilter/ebt_802_3.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ebt_802_3_mt(const struct sk_buff *skb, const struct xt_match_param *par)
return true;
}

static bool ebt_802_3_mt_check(const struct xt_mtchk_param *par)
static int ebt_802_3_mt_check(const struct xt_mtchk_param *par)
{
const struct ebt_802_3_info *info = par->matchinfo;

Expand Down
2 changes: 1 addition & 1 deletion net/bridge/netfilter/ebt_among.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ ebt_among_mt(const struct sk_buff *skb, const struct xt_match_param *par)
return true;
}

static bool ebt_among_mt_check(const struct xt_mtchk_param *par)
static int ebt_among_mt_check(const struct xt_mtchk_param *par)
{
const struct ebt_among_info *info = par->matchinfo;
const struct ebt_entry_match *em =
Expand Down
2 changes: 1 addition & 1 deletion net/bridge/netfilter/ebt_arp.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ ebt_arp_mt(const struct sk_buff *skb, const struct xt_match_param *par)
return true;
}

static bool ebt_arp_mt_check(const struct xt_mtchk_param *par)
static int ebt_arp_mt_check(const struct xt_mtchk_param *par)
{
const struct ebt_arp_info *info = par->matchinfo;
const struct ebt_entry *e = par->entryinfo;
Expand Down
2 changes: 1 addition & 1 deletion net/bridge/netfilter/ebt_ip.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ ebt_ip_mt(const struct sk_buff *skb, const struct xt_match_param *par)
return true;
}

static bool ebt_ip_mt_check(const struct xt_mtchk_param *par)
static int ebt_ip_mt_check(const struct xt_mtchk_param *par)
{
const struct ebt_ip_info *info = par->matchinfo;
const struct ebt_entry *e = par->entryinfo;
Expand Down
2 changes: 1 addition & 1 deletion net/bridge/netfilter/ebt_ip6.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ ebt_ip6_mt(const struct sk_buff *skb, const struct xt_match_param *par)
return true;
}

static bool ebt_ip6_mt_check(const struct xt_mtchk_param *par)
static int ebt_ip6_mt_check(const struct xt_mtchk_param *par)
{
const struct ebt_entry *e = par->entryinfo;
struct ebt_ip6_info *info = par->matchinfo;
Expand Down
2 changes: 1 addition & 1 deletion net/bridge/netfilter/ebt_limit.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ user2credits(u_int32_t user)
return (user * HZ * CREDITS_PER_JIFFY) / EBT_LIMIT_SCALE;
}

static bool ebt_limit_mt_check(const struct xt_mtchk_param *par)
static int ebt_limit_mt_check(const struct xt_mtchk_param *par)
{
struct ebt_limit_info *info = par->matchinfo;

Expand Down
2 changes: 1 addition & 1 deletion net/bridge/netfilter/ebt_mark_m.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ebt_mark_mt(const struct sk_buff *skb, const struct xt_match_param *par)
return ((skb->mark & info->mask) == info->mark) ^ info->invert;
}

static bool ebt_mark_mt_check(const struct xt_mtchk_param *par)
static int ebt_mark_mt_check(const struct xt_mtchk_param *par)
{
const struct ebt_mark_m_info *info = par->matchinfo;

Expand Down
2 changes: 1 addition & 1 deletion net/bridge/netfilter/ebt_pkttype.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ebt_pkttype_mt(const struct sk_buff *skb, const struct xt_match_param *par)
return (skb->pkt_type == info->pkt_type) ^ info->invert;
}

static bool ebt_pkttype_mt_check(const struct xt_mtchk_param *par)
static int ebt_pkttype_mt_check(const struct xt_mtchk_param *par)
{
const struct ebt_pkttype_info *info = par->matchinfo;

Expand Down
2 changes: 1 addition & 1 deletion net/bridge/netfilter/ebt_stp.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ ebt_stp_mt(const struct sk_buff *skb, const struct xt_match_param *par)
return true;
}

static bool ebt_stp_mt_check(const struct xt_mtchk_param *par)
static int ebt_stp_mt_check(const struct xt_mtchk_param *par)
{
const struct ebt_stp_info *info = par->matchinfo;
const uint8_t bridge_ula[6] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x00};
Expand Down
2 changes: 1 addition & 1 deletion net/bridge/netfilter/ebt_vlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ ebt_vlan_mt(const struct sk_buff *skb, const struct xt_match_param *par)
return true;
}

static bool ebt_vlan_mt_check(const struct xt_mtchk_param *par)
static int ebt_vlan_mt_check(const struct xt_mtchk_param *par)
{
struct ebt_vlan_info *info = par->matchinfo;
const struct ebt_entry *e = par->entryinfo;
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/netfilter/ip_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -2176,7 +2176,7 @@ icmp_match(const struct sk_buff *skb, const struct xt_match_param *par)
!!(icmpinfo->invflags&IPT_ICMP_INV));
}

static bool icmp_checkentry(const struct xt_mtchk_param *par)
static int icmp_checkentry(const struct xt_mtchk_param *par)
{
const struct ipt_icmp *icmpinfo = par->matchinfo;

Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/netfilter/ipt_addrtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ addrtype_mt_v1(const struct sk_buff *skb, const struct xt_match_param *par)
return ret;
}

static bool addrtype_mt_checkentry_v1(const struct xt_mtchk_param *par)
static int addrtype_mt_checkentry_v1(const struct xt_mtchk_param *par)
{
struct ipt_addrtype_info_v1 *info = par->matchinfo;

Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/netfilter/ipt_ah.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static bool ah_mt(const struct sk_buff *skb, const struct xt_match_param *par)
!!(ahinfo->invflags & IPT_AH_INV_SPI));
}

static bool ah_mt_check(const struct xt_mtchk_param *par)
static int ah_mt_check(const struct xt_mtchk_param *par)
{
const struct ipt_ah *ahinfo = par->matchinfo;

Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/netfilter/ipt_ecn.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static bool ecn_mt(const struct sk_buff *skb, const struct xt_match_param *par)
return true;
}

static bool ecn_mt_check(const struct xt_mtchk_param *par)
static int ecn_mt_check(const struct xt_mtchk_param *par)
{
const struct ipt_ecn_info *info = par->matchinfo;
const struct ipt_ip *ip = par->entryinfo;
Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/netfilter/ip6_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -2209,7 +2209,7 @@ icmp6_match(const struct sk_buff *skb, const struct xt_match_param *par)
}

/* Called when user tries to insert an entry of this type. */
static bool icmp6_checkentry(const struct xt_mtchk_param *par)
static int icmp6_checkentry(const struct xt_mtchk_param *par)
{
const struct ip6t_icmp *icmpinfo = par->matchinfo;

Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/netfilter/ip6t_ah.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static bool ah_mt6(const struct sk_buff *skb, const struct xt_match_param *par)
!(ahinfo->hdrres && ah->reserved);
}

static bool ah_mt6_check(const struct xt_mtchk_param *par)
static int ah_mt6_check(const struct xt_mtchk_param *par)
{
const struct ip6t_ah *ahinfo = par->matchinfo;

Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/netfilter/ip6t_frag.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ frag_mt6(const struct sk_buff *skb, const struct xt_match_param *par)
(ntohs(fh->frag_off) & IP6_MF));
}

static bool frag_mt6_check(const struct xt_mtchk_param *par)
static int frag_mt6_check(const struct xt_mtchk_param *par)
{
const struct ip6t_frag *fraginfo = par->matchinfo;

Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/netfilter/ip6t_hbh.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ hbh_mt6(const struct sk_buff *skb, const struct xt_match_param *par)
return false;
}

static bool hbh_mt6_check(const struct xt_mtchk_param *par)
static int hbh_mt6_check(const struct xt_mtchk_param *par)
{
const struct ip6t_opts *optsinfo = par->matchinfo;

Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/netfilter/ip6t_ipv6header.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ ipv6header_mt6(const struct sk_buff *skb, const struct xt_match_param *par)
}
}

static bool ipv6header_mt6_check(const struct xt_mtchk_param *par)
static int ipv6header_mt6_check(const struct xt_mtchk_param *par)
{
const struct ip6t_ipv6header_info *info = par->matchinfo;

Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/netfilter/ip6t_mh.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static bool mh_mt6(const struct sk_buff *skb, const struct xt_match_param *par)
!!(mhinfo->invflags & IP6T_MH_INV_TYPE));
}

static bool mh_mt6_check(const struct xt_mtchk_param *par)
static int mh_mt6_check(const struct xt_mtchk_param *par)
{
const struct ip6t_mh *mhinfo = par->matchinfo;

Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/netfilter/ip6t_rt.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static bool rt_mt6(const struct sk_buff *skb, const struct xt_match_param *par)
return false;
}

static bool rt_mt6_check(const struct xt_mtchk_param *par)
static int rt_mt6_check(const struct xt_mtchk_param *par)
{
const struct ip6t_rt *rtinfo = par->matchinfo;

Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/xt_cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ xt_cluster_mt(const struct sk_buff *skb, const struct xt_match_param *par)
!!(info->flags & XT_CLUSTER_F_INV);
}

static bool xt_cluster_mt_checkentry(const struct xt_mtchk_param *par)
static int xt_cluster_mt_checkentry(const struct xt_mtchk_param *par)
{
struct xt_cluster_match_info *info = par->matchinfo;

Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/xt_connbytes.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ connbytes_mt(const struct sk_buff *skb, const struct xt_match_param *par)
return what >= sinfo->count.from;
}

static bool connbytes_mt_check(const struct xt_mtchk_param *par)
static int connbytes_mt_check(const struct xt_mtchk_param *par)
{
const struct xt_connbytes_info *sinfo = par->matchinfo;

Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/xt_connlimit.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ connlimit_mt(const struct sk_buff *skb, const struct xt_match_param *par)
return false;
}

static bool connlimit_mt_check(const struct xt_mtchk_param *par)
static int connlimit_mt_check(const struct xt_mtchk_param *par)
{
struct xt_connlimit_info *info = par->matchinfo;
unsigned int i;
Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/xt_connmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ connmark_mt(const struct sk_buff *skb, const struct xt_match_param *par)
return ((ct->mark & info->mask) == info->mark) ^ info->invert;
}

static bool connmark_mt_check(const struct xt_mtchk_param *par)
static int connmark_mt_check(const struct xt_mtchk_param *par)
{
if (nf_ct_l3proto_try_module_get(par->family) < 0) {
pr_info("cannot load conntrack support for proto=%u\n",
Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/xt_conntrack.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ conntrack_mt_v2(const struct sk_buff *skb, const struct xt_match_param *par)
return conntrack_mt(skb, par, info->state_mask, info->status_mask);
}

static bool conntrack_mt_check(const struct xt_mtchk_param *par)
static int conntrack_mt_check(const struct xt_mtchk_param *par)
{
if (nf_ct_l3proto_try_module_get(par->family) < 0) {
pr_info("cannot load conntrack support for proto=%u\n",
Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/xt_dccp.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ dccp_mt(const struct sk_buff *skb, const struct xt_match_param *par)
XT_DCCP_OPTION, info->flags, info->invflags);
}

static bool dccp_mt_check(const struct xt_mtchk_param *par)
static int dccp_mt_check(const struct xt_mtchk_param *par)
{
const struct xt_dccp_info *info = par->matchinfo;

Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/xt_dscp.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ dscp_mt6(const struct sk_buff *skb, const struct xt_match_param *par)
return (dscp == info->dscp) ^ !!info->invert;
}

static bool dscp_mt_check(const struct xt_mtchk_param *par)
static int dscp_mt_check(const struct xt_mtchk_param *par)
{
const struct xt_dscp_info *info = par->matchinfo;

Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/xt_esp.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static bool esp_mt(const struct sk_buff *skb, const struct xt_match_param *par)
!!(espinfo->invflags & XT_ESP_INV_SPI));
}

static bool esp_mt_check(const struct xt_mtchk_param *par)
static int esp_mt_check(const struct xt_mtchk_param *par)
{
const struct xt_esp *espinfo = par->matchinfo;

Expand Down
4 changes: 2 additions & 2 deletions net/netfilter/xt_hashlimit.c
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ hashlimit_mt(const struct sk_buff *skb, const struct xt_match_param *par)
return false;
}

static bool hashlimit_mt_check_v0(const struct xt_mtchk_param *par)
static int hashlimit_mt_check_v0(const struct xt_mtchk_param *par)
{
struct net *net = par->net;
struct xt_hashlimit_info *r = par->matchinfo;
Expand Down Expand Up @@ -707,7 +707,7 @@ static bool hashlimit_mt_check_v0(const struct xt_mtchk_param *par)
return true;
}

static bool hashlimit_mt_check(const struct xt_mtchk_param *par)
static int hashlimit_mt_check(const struct xt_mtchk_param *par)
{
struct net *net = par->net;
struct xt_hashlimit_mtinfo1 *info = par->matchinfo;
Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/xt_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ helper_mt(const struct sk_buff *skb, const struct xt_match_param *par)
return ret;
}

static bool helper_mt_check(const struct xt_mtchk_param *par)
static int helper_mt_check(const struct xt_mtchk_param *par)
{
struct xt_helper_info *info = par->matchinfo;

Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/xt_limit.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ user2credits(u_int32_t user)
return (user * HZ * CREDITS_PER_JIFFY) / XT_LIMIT_SCALE;
}

static bool limit_mt_check(const struct xt_mtchk_param *par)
static int limit_mt_check(const struct xt_mtchk_param *par)
{
struct xt_rateinfo *r = par->matchinfo;
struct xt_limit_priv *priv;
Expand Down
8 changes: 4 additions & 4 deletions net/netfilter/xt_multiport.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ check(u_int16_t proto,
&& count <= XT_MULTI_PORTS;
}

static bool multiport_mt_check_v0(const struct xt_mtchk_param *par)
static int multiport_mt_check_v0(const struct xt_mtchk_param *par)
{
const struct ipt_ip *ip = par->entryinfo;
const struct xt_multiport *multiinfo = par->matchinfo;
Expand All @@ -161,7 +161,7 @@ static bool multiport_mt_check_v0(const struct xt_mtchk_param *par)
multiinfo->count);
}

static bool multiport_mt_check(const struct xt_mtchk_param *par)
static int multiport_mt_check(const struct xt_mtchk_param *par)
{
const struct ipt_ip *ip = par->entryinfo;
const struct xt_multiport_v1 *multiinfo = par->matchinfo;
Expand All @@ -170,7 +170,7 @@ static bool multiport_mt_check(const struct xt_mtchk_param *par)
multiinfo->count);
}

static bool multiport_mt6_check_v0(const struct xt_mtchk_param *par)
static int multiport_mt6_check_v0(const struct xt_mtchk_param *par)
{
const struct ip6t_ip6 *ip = par->entryinfo;
const struct xt_multiport *multiinfo = par->matchinfo;
Expand All @@ -179,7 +179,7 @@ static bool multiport_mt6_check_v0(const struct xt_mtchk_param *par)
multiinfo->count);
}

static bool multiport_mt6_check(const struct xt_mtchk_param *par)
static int multiport_mt6_check(const struct xt_mtchk_param *par)
{
const struct ip6t_ip6 *ip = par->entryinfo;
const struct xt_multiport_v1 *multiinfo = par->matchinfo;
Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/xt_physdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ physdev_mt(const struct sk_buff *skb, const struct xt_match_param *par)
return (!!ret ^ !(info->invert & XT_PHYSDEV_OP_OUT));
}

static bool physdev_mt_check(const struct xt_mtchk_param *par)
static int physdev_mt_check(const struct xt_mtchk_param *par)
{
const struct xt_physdev_info *info = par->matchinfo;

Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/xt_policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ policy_mt(const struct sk_buff *skb, const struct xt_match_param *par)
return ret;
}

static bool policy_mt_check(const struct xt_mtchk_param *par)
static int policy_mt_check(const struct xt_mtchk_param *par)
{
const struct xt_policy_info *info = par->matchinfo;

Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/xt_quota.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ quota_mt(const struct sk_buff *skb, const struct xt_match_param *par)
return ret;
}

static bool quota_mt_check(const struct xt_mtchk_param *par)
static int quota_mt_check(const struct xt_mtchk_param *par)
{
struct xt_quota_info *q = par->matchinfo;

Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/xt_rateest.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ xt_rateest_mt(const struct sk_buff *skb, const struct xt_match_param *par)
return ret;
}

static bool xt_rateest_mt_checkentry(const struct xt_mtchk_param *par)
static int xt_rateest_mt_checkentry(const struct xt_mtchk_param *par)
{
struct xt_rateest_match_info *info = par->matchinfo;
struct xt_rateest *est1, *est2;
Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/xt_recent.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ recent_mt(const struct sk_buff *skb, const struct xt_match_param *par)
return ret;
}

static bool recent_mt_check(const struct xt_mtchk_param *par)
static int recent_mt_check(const struct xt_mtchk_param *par)
{
struct recent_net *recent_net = recent_pernet(par->net);
const struct xt_recent_mtinfo *info = par->matchinfo;
Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/xt_sctp.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ sctp_mt(const struct sk_buff *skb, const struct xt_match_param *par)
XT_SCTP_CHUNK_TYPES, info->flags, info->invflags);
}

static bool sctp_mt_check(const struct xt_mtchk_param *par)
static int sctp_mt_check(const struct xt_mtchk_param *par)
{
const struct xt_sctp_info *info = par->matchinfo;

Expand Down
Loading

0 comments on commit b0f3845

Please sign in to comment.