netfilter: avoid using skb->nf_bridge directly
This pointer is going to be removed soon, so use the existing helpers in more places to avoid noise when the removal happens. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
8239d57904
commit
c4b0e771f9
@ -156,22 +156,20 @@ nf_log_dump_packet_common(struct nf_log_buf *m, u_int8_t pf,
|
||||
const struct net_device *out,
|
||||
const struct nf_loginfo *loginfo, const char *prefix)
|
||||
{
|
||||
const struct net_device *physoutdev __maybe_unused;
|
||||
const struct net_device *physindev __maybe_unused;
|
||||
|
||||
nf_log_buf_add(m, KERN_SOH "%c%sIN=%s OUT=%s ",
|
||||
'0' + loginfo->u.log.level, prefix,
|
||||
in ? in->name : "",
|
||||
out ? out->name : "");
|
||||
#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
|
||||
if (skb->nf_bridge) {
|
||||
const struct net_device *physindev;
|
||||
const struct net_device *physoutdev;
|
||||
|
||||
physindev = nf_bridge_get_physindev(skb);
|
||||
if (physindev && in != physindev)
|
||||
nf_log_buf_add(m, "PHYSIN=%s ", physindev->name);
|
||||
physoutdev = nf_bridge_get_physoutdev(skb);
|
||||
if (physoutdev && out != physoutdev)
|
||||
nf_log_buf_add(m, "PHYSOUT=%s ", physoutdev->name);
|
||||
}
|
||||
physindev = nf_bridge_get_physindev(skb);
|
||||
if (physindev && in != physindev)
|
||||
nf_log_buf_add(m, "PHYSIN=%s ", physindev->name);
|
||||
physoutdev = nf_bridge_get_physoutdev(skb);
|
||||
if (physoutdev && out != physoutdev)
|
||||
nf_log_buf_add(m, "PHYSOUT=%s ", physoutdev->name);
|
||||
#endif
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(nf_log_dump_packet_common);
|
||||
|
@ -46,6 +46,24 @@ void nf_unregister_queue_handler(struct net *net)
|
||||
}
|
||||
EXPORT_SYMBOL(nf_unregister_queue_handler);
|
||||
|
||||
static void nf_queue_entry_release_br_nf_refs(struct sk_buff *skb)
|
||||
{
|
||||
#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
|
||||
struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb);
|
||||
|
||||
if (nf_bridge) {
|
||||
struct net_device *physdev;
|
||||
|
||||
physdev = nf_bridge_get_physindev(skb);
|
||||
if (physdev)
|
||||
dev_put(physdev);
|
||||
physdev = nf_bridge_get_physoutdev(skb);
|
||||
if (physdev)
|
||||
dev_put(physdev);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void nf_queue_entry_release_refs(struct nf_queue_entry *entry)
|
||||
{
|
||||
struct nf_hook_state *state = &entry->state;
|
||||
@ -57,20 +75,28 @@ void nf_queue_entry_release_refs(struct nf_queue_entry *entry)
|
||||
dev_put(state->out);
|
||||
if (state->sk)
|
||||
sock_put(state->sk);
|
||||
|
||||
nf_queue_entry_release_br_nf_refs(entry->skb);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(nf_queue_entry_release_refs);
|
||||
|
||||
static void nf_queue_entry_get_br_nf_refs(struct sk_buff *skb)
|
||||
{
|
||||
#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
|
||||
if (entry->skb->nf_bridge) {
|
||||
struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb);
|
||||
|
||||
if (nf_bridge) {
|
||||
struct net_device *physdev;
|
||||
|
||||
physdev = nf_bridge_get_physindev(entry->skb);
|
||||
physdev = nf_bridge_get_physindev(skb);
|
||||
if (physdev)
|
||||
dev_put(physdev);
|
||||
physdev = nf_bridge_get_physoutdev(entry->skb);
|
||||
dev_hold(physdev);
|
||||
physdev = nf_bridge_get_physoutdev(skb);
|
||||
if (physdev)
|
||||
dev_put(physdev);
|
||||
dev_hold(physdev);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(nf_queue_entry_release_refs);
|
||||
|
||||
/* Bump dev refs so they don't vanish while packet is out */
|
||||
void nf_queue_entry_get_refs(struct nf_queue_entry *entry)
|
||||
@ -83,18 +109,8 @@ void nf_queue_entry_get_refs(struct nf_queue_entry *entry)
|
||||
dev_hold(state->out);
|
||||
if (state->sk)
|
||||
sock_hold(state->sk);
|
||||
#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
|
||||
if (entry->skb->nf_bridge) {
|
||||
struct net_device *physdev;
|
||||
|
||||
physdev = nf_bridge_get_physindev(entry->skb);
|
||||
if (physdev)
|
||||
dev_hold(physdev);
|
||||
physdev = nf_bridge_get_physoutdev(entry->skb);
|
||||
if (physdev)
|
||||
dev_hold(physdev);
|
||||
}
|
||||
#endif
|
||||
nf_queue_entry_get_br_nf_refs(entry->skb);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(nf_queue_entry_get_refs);
|
||||
|
||||
|
@ -727,13 +727,13 @@ nf_queue_entry_dup(struct nf_queue_entry *e)
|
||||
*/
|
||||
static void nf_bridge_adjust_skb_data(struct sk_buff *skb)
|
||||
{
|
||||
if (skb->nf_bridge)
|
||||
if (nf_bridge_info_get(skb))
|
||||
__skb_push(skb, skb->network_header - skb->mac_header);
|
||||
}
|
||||
|
||||
static void nf_bridge_adjust_segmented_data(struct sk_buff *skb)
|
||||
{
|
||||
if (skb->nf_bridge)
|
||||
if (nf_bridge_info_get(skb))
|
||||
__skb_pull(skb, skb->network_header - skb->mac_header);
|
||||
}
|
||||
#else
|
||||
@ -904,23 +904,22 @@ nfqnl_set_mode(struct nfqnl_instance *queue,
|
||||
static int
|
||||
dev_cmp(struct nf_queue_entry *entry, unsigned long ifindex)
|
||||
{
|
||||
#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
|
||||
int physinif, physoutif;
|
||||
|
||||
physinif = nf_bridge_get_physinif(entry->skb);
|
||||
physoutif = nf_bridge_get_physoutif(entry->skb);
|
||||
|
||||
if (physinif == ifindex || physoutif == ifindex)
|
||||
return 1;
|
||||
#endif
|
||||
if (entry->state.in)
|
||||
if (entry->state.in->ifindex == ifindex)
|
||||
return 1;
|
||||
if (entry->state.out)
|
||||
if (entry->state.out->ifindex == ifindex)
|
||||
return 1;
|
||||
#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
|
||||
if (entry->skb->nf_bridge) {
|
||||
int physinif, physoutif;
|
||||
|
||||
physinif = nf_bridge_get_physinif(entry->skb);
|
||||
physoutif = nf_bridge_get_physoutif(entry->skb);
|
||||
|
||||
if (physinif == ifindex || physoutif == ifindex)
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ physdev_mt(const struct sk_buff *skb, struct xt_action_param *par)
|
||||
/* Not a bridged IP packet or no info available yet:
|
||||
* LOCAL_OUT/mangle and LOCAL_OUT/nat don't know if
|
||||
* the destination device will be a bridge. */
|
||||
if (!skb->nf_bridge) {
|
||||
if (!nf_bridge_info_exists(skb)) {
|
||||
/* Return MATCH if the invert flags of the used options are on */
|
||||
if ((info->bitmask & XT_PHYSDEV_OP_BRIDGED) &&
|
||||
!(info->invert & XT_PHYSDEV_OP_BRIDGED))
|
||||
|
Reference in New Issue
Block a user