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

Commit 7eb35586 authored by Jan Engelhardt's avatar Jan Engelhardt Committed by Patrick McHardy
Browse files

netfilter: xtables: move extension arguments into compound structure (4/6)



This patch does this for target extensions' target functions.

Signed-off-by: default avatarJan Engelhardt <jengelh@medozas.de>
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
parent 6be3d859
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -218,6 +218,22 @@ struct xt_mtdtor_param {
	void *matchinfo;
};

/**
 * struct xt_target_param - parameters for target extensions' target functions
 *
 * @hooknum:	hook through which this target was invoked
 * @target:	struct xt_target through which this function was invoked
 * @targinfo:	per-target data
 *
 * Other fields see above.
 */
struct xt_target_param {
	const struct net_device *in, *out;
	unsigned int hooknum;
	const struct xt_target *target;
	const void *targinfo;
};

struct xt_match
{
	struct list_head list;
@@ -269,11 +285,7 @@ struct xt_target
	   must now handle non-linear skbs, using skb_copy_bits and
	   skb_ip_make_writable. */
	unsigned int (*target)(struct sk_buff *skb,
			       const struct net_device *in,
			       const struct net_device *out,
			       unsigned int hooknum,
			       const struct xt_target *target,
			       const void *targinfo);
			       const struct xt_target_param *);

	/* Called when user tries to insert an entry of this type:
           hook_mask is a bitmask of hooks from which it can be
+3 −5
Original line number Diff line number Diff line
@@ -16,11 +16,9 @@
#include <linux/netfilter_bridge/ebt_arpreply.h>

static unsigned int
ebt_arpreply_tg(struct sk_buff *skb, const struct net_device *in,
		const struct net_device *out, unsigned int hook_nr,
		const struct xt_target *target, const void *data)
ebt_arpreply_tg(struct sk_buff *skb, const struct xt_target_param *par)
{
	const struct ebt_arpreply_info *info = data;
	const struct ebt_arpreply_info *info = par->targinfo;
	const __be32 *siptr, *diptr;
	__be32 _sip, _dip;
	const struct arphdr *ap;
@@ -53,7 +51,7 @@ ebt_arpreply_tg(struct sk_buff *skb, const struct net_device *in,
	if (diptr == NULL)
		return EBT_DROP;

	arp_send(ARPOP_REPLY, ETH_P_ARP, *siptr, (struct net_device *)in,
	arp_send(ARPOP_REPLY, ETH_P_ARP, *siptr, (struct net_device *)par->in,
		 *diptr, shp, info->mac, shp);

	return info->target;
+2 −4
Original line number Diff line number Diff line
@@ -15,11 +15,9 @@
#include <linux/netfilter_bridge/ebt_nat.h>

static unsigned int
ebt_dnat_tg(struct sk_buff *skb, const struct net_device *in,
	    const struct net_device *out, unsigned int hook_nr,
	    const struct xt_target *target, const void *data)
ebt_dnat_tg(struct sk_buff *skb, const struct xt_target_param *par)
{
	const struct ebt_nat_info *info = data;
	const struct ebt_nat_info *info = par->targinfo;

	if (!skb_make_writable(skb, 0))
		return EBT_DROP;
+6 −8
Original line number Diff line number Diff line
@@ -195,11 +195,9 @@ out:
}

static unsigned int
ebt_log_tg(struct sk_buff *skb, const struct net_device *in,
	   const struct net_device *out, unsigned int hooknr,
	   const struct xt_target *target, const void *data)
ebt_log_tg(struct sk_buff *skb, const struct xt_target_param *par)
{
	const struct ebt_log_info *info = data;
	const struct ebt_log_info *info = par->targinfo;
	struct nf_loginfo li;

	li.type = NF_LOG_TYPE_LOG;
@@ -207,11 +205,11 @@ ebt_log_tg(struct sk_buff *skb, const struct net_device *in,
	li.u.log.logflags = info->bitmask;

	if (info->bitmask & EBT_LOG_NFLOG)
		nf_log_packet(NFPROTO_BRIDGE, hooknr, skb, in, out, &li,
			      "%s", info->prefix);
		nf_log_packet(NFPROTO_BRIDGE, par->hooknum, skb, par->in,
		              par->out, &li, "%s", info->prefix);
	else
		ebt_log_packet(NFPROTO_BRIDGE, hooknr, skb, in, out, &li,
			       info->prefix);
		ebt_log_packet(NFPROTO_BRIDGE, par->hooknum, skb, par->in,
		               par->out, &li, info->prefix);
	return EBT_CONTINUE;
}

+2 −4
Original line number Diff line number Diff line
@@ -19,11 +19,9 @@
#include <linux/netfilter_bridge/ebt_mark_t.h>

static unsigned int
ebt_mark_tg(struct sk_buff *skb, const struct net_device *in,
	    const struct net_device *out, unsigned int hook_nr,
	    const struct xt_target *target, const void *data)
ebt_mark_tg(struct sk_buff *skb, const struct xt_target_param *par)
{
	const struct ebt_mark_t_info *info = data;
	const struct ebt_mark_t_info *info = par->targinfo;
	int action = info->target & -16;

	if (action == MARK_SET_VALUE)
Loading