mirror of
https://github.com/torvalds/linux.git
synced 2024-11-17 09:31:50 +00:00
netfilter: nf_conntrack_sip: remove direct dependency on IPv6
Previous implementation was not usable with CONFIG_IPV6=m.
Fixes: a3419ce335
("netfilter: nf_conntrack_sip: add sip_external_media logic")
Signed-off-by: Alin Nastac <alin.nastac@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
parent
4ec850e5df
commit
29b0b5d565
@ -20,9 +20,9 @@
|
|||||||
#include <linux/udp.h>
|
#include <linux/udp.h>
|
||||||
#include <linux/tcp.h>
|
#include <linux/tcp.h>
|
||||||
#include <linux/netfilter.h>
|
#include <linux/netfilter.h>
|
||||||
|
#include <linux/netfilter_ipv4.h>
|
||||||
|
#include <linux/netfilter_ipv6.h>
|
||||||
|
|
||||||
#include <net/route.h>
|
|
||||||
#include <net/ip6_route.h>
|
|
||||||
#include <net/netfilter/nf_conntrack.h>
|
#include <net/netfilter/nf_conntrack.h>
|
||||||
#include <net/netfilter/nf_conntrack_core.h>
|
#include <net/netfilter/nf_conntrack_core.h>
|
||||||
#include <net/netfilter/nf_conntrack_expect.h>
|
#include <net/netfilter/nf_conntrack_expect.h>
|
||||||
@ -871,38 +871,33 @@ static int set_expected_rtp_rtcp(struct sk_buff *skb, unsigned int protoff,
|
|||||||
} else if (sip_external_media) {
|
} else if (sip_external_media) {
|
||||||
struct net_device *dev = skb_dst(skb)->dev;
|
struct net_device *dev = skb_dst(skb)->dev;
|
||||||
struct net *net = dev_net(dev);
|
struct net *net = dev_net(dev);
|
||||||
struct rtable *rt;
|
struct flowi fl;
|
||||||
struct flowi4 fl4 = {};
|
|
||||||
#if IS_ENABLED(CONFIG_IPV6)
|
|
||||||
struct flowi6 fl6 = {};
|
|
||||||
#endif
|
|
||||||
struct dst_entry *dst = NULL;
|
struct dst_entry *dst = NULL;
|
||||||
|
|
||||||
|
memset(&fl, 0, sizeof(fl));
|
||||||
|
|
||||||
switch (nf_ct_l3num(ct)) {
|
switch (nf_ct_l3num(ct)) {
|
||||||
case NFPROTO_IPV4:
|
case NFPROTO_IPV4:
|
||||||
fl4.daddr = daddr->ip;
|
fl.u.ip4.daddr = daddr->ip;
|
||||||
rt = ip_route_output_key(net, &fl4);
|
nf_ip_route(net, &dst, &fl, false);
|
||||||
if (!IS_ERR(rt))
|
|
||||||
dst = &rt->dst;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if IS_ENABLED(CONFIG_IPV6)
|
|
||||||
case NFPROTO_IPV6:
|
case NFPROTO_IPV6:
|
||||||
fl6.daddr = daddr->in6;
|
fl.u.ip6.daddr = daddr->in6;
|
||||||
dst = ip6_route_output(net, NULL, &fl6);
|
nf_ip6_route(net, &dst, &fl, false);
|
||||||
if (dst->error) {
|
|
||||||
dst_release(dst);
|
|
||||||
dst = NULL;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't predict any conntracks when media endpoint is reachable
|
/* Don't predict any conntracks when media endpoint is reachable
|
||||||
* through the same interface as the signalling peer.
|
* through the same interface as the signalling peer.
|
||||||
*/
|
*/
|
||||||
if (dst && dst->dev == dev)
|
if (dst) {
|
||||||
return NF_ACCEPT;
|
bool external_media = (dst->dev == dev);
|
||||||
|
|
||||||
|
dst_release(dst);
|
||||||
|
if (external_media)
|
||||||
|
return NF_ACCEPT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We need to check whether the registration exists before attempting
|
/* We need to check whether the registration exists before attempting
|
||||||
|
Loading…
Reference in New Issue
Block a user