Commit 212440a7 authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

[NETFILTER]: nf_conntrack_sip: remove redundant function arguments

The conntrack reference and ctinfo can be derived from the packet.
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2a6cfb22
...@@ -22,15 +22,12 @@ enum sip_header_pos { ...@@ -22,15 +22,12 @@ enum sip_header_pos {
}; };
extern unsigned int (*nf_nat_sip_hook)(struct sk_buff *skb, extern unsigned int (*nf_nat_sip_hook)(struct sk_buff *skb,
enum ip_conntrack_info ctinfo,
struct nf_conn *ct,
const char **dptr, const char **dptr,
unsigned int *datalen); unsigned int *datalen);
extern unsigned int (*nf_nat_sdp_hook)(struct sk_buff *skb, extern unsigned int (*nf_nat_sdp_hook)(struct sk_buff *skb,
enum ip_conntrack_info ctinfo,
struct nf_conntrack_expect *exp,
const char **dptr, const char **dptr,
unsigned int *datalen); unsigned int *datalen,
struct nf_conntrack_expect *exp);
extern int ct_sip_get_info(const struct nf_conn *ct, const char *dptr, extern int ct_sip_get_info(const struct nf_conn *ct, const char *dptr,
size_t dlen, unsigned int *matchoff, size_t dlen, unsigned int *matchoff,
......
...@@ -78,11 +78,12 @@ static unsigned int mangle_packet(struct sk_buff *skb, ...@@ -78,11 +78,12 @@ static unsigned int mangle_packet(struct sk_buff *skb,
return 1; return 1;
} }
static int map_sip_addr(struct sk_buff *skb, enum ip_conntrack_info ctinfo, static int map_sip_addr(struct sk_buff *skb,
struct nf_conn *ct,
const char **dptr, unsigned int *datalen, const char **dptr, unsigned int *datalen,
enum sip_header_pos pos, struct addr_map *map) enum sip_header_pos pos, struct addr_map *map)
{ {
enum ip_conntrack_info ctinfo;
struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo); enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
unsigned int matchlen, matchoff, addrlen; unsigned int matchlen, matchoff, addrlen;
char *addr; char *addr;
...@@ -109,10 +110,10 @@ static int map_sip_addr(struct sk_buff *skb, enum ip_conntrack_info ctinfo, ...@@ -109,10 +110,10 @@ static int map_sip_addr(struct sk_buff *skb, enum ip_conntrack_info ctinfo,
} }
static unsigned int ip_nat_sip(struct sk_buff *skb, static unsigned int ip_nat_sip(struct sk_buff *skb,
enum ip_conntrack_info ctinfo,
struct nf_conn *ct,
const char **dptr, unsigned int *datalen) const char **dptr, unsigned int *datalen)
{ {
enum ip_conntrack_info ctinfo;
struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
enum sip_header_pos pos; enum sip_header_pos pos;
struct addr_map map; struct addr_map map;
...@@ -134,25 +135,25 @@ static unsigned int ip_nat_sip(struct sk_buff *skb, ...@@ -134,25 +135,25 @@ static unsigned int ip_nat_sip(struct sk_buff *skb,
else else
pos = POS_REQ_URI; pos = POS_REQ_URI;
if (!map_sip_addr(skb, ctinfo, ct, dptr, datalen, pos, &map)) if (!map_sip_addr(skb, dptr, datalen, pos, &map))
return NF_DROP; return NF_DROP;
} }
if (!map_sip_addr(skb, ctinfo, ct, dptr, datalen, POS_FROM, &map) || if (!map_sip_addr(skb, dptr, datalen, POS_FROM, &map) ||
!map_sip_addr(skb, ctinfo, ct, dptr, datalen, POS_TO, &map) || !map_sip_addr(skb, dptr, datalen, POS_TO, &map) ||
!map_sip_addr(skb, ctinfo, ct, dptr, datalen, POS_VIA, &map) || !map_sip_addr(skb, dptr, datalen, POS_VIA, &map) ||
!map_sip_addr(skb, ctinfo, ct, dptr, datalen, POS_CONTACT, &map)) !map_sip_addr(skb, dptr, datalen, POS_CONTACT, &map))
return NF_DROP; return NF_DROP;
return NF_ACCEPT; return NF_ACCEPT;
} }
static unsigned int mangle_sip_packet(struct sk_buff *skb, static unsigned int mangle_sip_packet(struct sk_buff *skb,
enum ip_conntrack_info ctinfo,
struct nf_conn *ct,
const char **dptr, unsigned int *datalen, const char **dptr, unsigned int *datalen,
char *buffer, int bufflen, char *buffer, int bufflen,
enum sip_header_pos pos) enum sip_header_pos pos)
{ {
enum ip_conntrack_info ctinfo;
struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
unsigned int matchlen, matchoff; unsigned int matchlen, matchoff;
if (ct_sip_get_info(ct, *dptr, *datalen, &matchoff, &matchlen, if (ct_sip_get_info(ct, *dptr, *datalen, &matchoff, &matchlen,
...@@ -164,10 +165,10 @@ static unsigned int mangle_sip_packet(struct sk_buff *skb, ...@@ -164,10 +165,10 @@ static unsigned int mangle_sip_packet(struct sk_buff *skb,
} }
static int mangle_content_len(struct sk_buff *skb, static int mangle_content_len(struct sk_buff *skb,
enum ip_conntrack_info ctinfo,
struct nf_conn *ct,
const char **dptr, unsigned int *datalen) const char **dptr, unsigned int *datalen)
{ {
enum ip_conntrack_info ctinfo;
struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
unsigned int matchoff, matchlen; unsigned int matchoff, matchlen;
char buffer[sizeof("65536")]; char buffer[sizeof("65536")];
int bufflen; int bufflen;
...@@ -204,21 +205,21 @@ static unsigned int mangle_sdp(struct sk_buff *skb, ...@@ -204,21 +205,21 @@ static unsigned int mangle_sdp(struct sk_buff *skb,
/* Mangle owner and contact info. */ /* Mangle owner and contact info. */
bufflen = sprintf(buffer, "%u.%u.%u.%u", NIPQUAD(newip)); bufflen = sprintf(buffer, "%u.%u.%u.%u", NIPQUAD(newip));
if (!mangle_sip_packet(skb, ctinfo, ct, dptr, datalen, if (!mangle_sip_packet(skb, dptr, datalen, buffer, bufflen,
buffer, bufflen, POS_OWNER_IP4)) POS_OWNER_IP4))
return 0; return 0;
if (!mangle_sip_packet(skb, ctinfo, ct, dptr, datalen, if (!mangle_sip_packet(skb, dptr, datalen, buffer, bufflen,
buffer, bufflen, POS_CONNECTION_IP4)) POS_CONNECTION_IP4))
return 0; return 0;
/* Mangle media port. */ /* Mangle media port. */
bufflen = sprintf(buffer, "%u", port); bufflen = sprintf(buffer, "%u", port);
if (!mangle_sip_packet(skb, ctinfo, ct, dptr, datalen, if (!mangle_sip_packet(skb, dptr, datalen, buffer, bufflen,
buffer, bufflen, POS_MEDIA)) POS_MEDIA))
return 0; return 0;
return mangle_content_len(skb, ctinfo, ct, dptr, datalen); return mangle_content_len(skb, dptr, datalen);
} }
static void ip_nat_sdp_expect(struct nf_conn *ct, static void ip_nat_sdp_expect(struct nf_conn *ct,
...@@ -245,11 +246,11 @@ static void ip_nat_sdp_expect(struct nf_conn *ct, ...@@ -245,11 +246,11 @@ static void ip_nat_sdp_expect(struct nf_conn *ct,
/* So, this packet has hit the connection tracking matching code. /* So, this packet has hit the connection tracking matching code.
Mangle it, and change the expectation to match the new version. */ Mangle it, and change the expectation to match the new version. */
static unsigned int ip_nat_sdp(struct sk_buff *skb, static unsigned int ip_nat_sdp(struct sk_buff *skb,
enum ip_conntrack_info ctinfo, const char **dptr, unsigned int *datalen,
struct nf_conntrack_expect *exp, struct nf_conntrack_expect *exp)
const char **dptr, unsigned int *datalen)
{ {
struct nf_conn *ct = exp->master; enum ip_conntrack_info ctinfo;
struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo); enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
__be32 newip; __be32 newip;
u_int16_t port; u_int16_t port;
......
...@@ -37,17 +37,14 @@ module_param(sip_timeout, uint, 0600); ...@@ -37,17 +37,14 @@ module_param(sip_timeout, uint, 0600);
MODULE_PARM_DESC(sip_timeout, "timeout for the master SIP session"); MODULE_PARM_DESC(sip_timeout, "timeout for the master SIP session");
unsigned int (*nf_nat_sip_hook)(struct sk_buff *skb, unsigned int (*nf_nat_sip_hook)(struct sk_buff *skb,
enum ip_conntrack_info ctinfo,
struct nf_conn *ct,
const char **dptr, const char **dptr,
unsigned int *datalen) __read_mostly; unsigned int *datalen) __read_mostly;
EXPORT_SYMBOL_GPL(nf_nat_sip_hook); EXPORT_SYMBOL_GPL(nf_nat_sip_hook);
unsigned int (*nf_nat_sdp_hook)(struct sk_buff *skb, unsigned int (*nf_nat_sdp_hook)(struct sk_buff *skb,
enum ip_conntrack_info ctinfo,
struct nf_conntrack_expect *exp,
const char **dptr, const char **dptr,
unsigned int *datalen) __read_mostly; unsigned int *datalen,
struct nf_conntrack_expect *exp) __read_mostly;
EXPORT_SYMBOL_GPL(nf_nat_sdp_hook); EXPORT_SYMBOL_GPL(nf_nat_sdp_hook);
static int digits_len(const struct nf_conn *, const char *, const char *, int *); static int digits_len(const struct nf_conn *, const char *, const char *, int *);
...@@ -367,13 +364,12 @@ int ct_sip_get_info(const struct nf_conn *ct, ...@@ -367,13 +364,12 @@ int ct_sip_get_info(const struct nf_conn *ct,
EXPORT_SYMBOL_GPL(ct_sip_get_info); EXPORT_SYMBOL_GPL(ct_sip_get_info);
static int set_expected_rtp(struct sk_buff *skb, static int set_expected_rtp(struct sk_buff *skb,
struct nf_conn *ct, const char **dptr, unsigned int *datalen,
enum ip_conntrack_info ctinfo, union nf_inet_addr *addr, __be16 port)
union nf_inet_addr *addr,
__be16 port,
const char **dptr, unsigned int *datalen)
{ {
struct nf_conntrack_expect *exp; struct nf_conntrack_expect *exp;
enum ip_conntrack_info ctinfo;
struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo); enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
int family = ct->tuplehash[!dir].tuple.src.l3num; int family = ct->tuplehash[!dir].tuple.src.l3num;
int ret; int ret;
...@@ -388,7 +384,7 @@ static int set_expected_rtp(struct sk_buff *skb, ...@@ -388,7 +384,7 @@ static int set_expected_rtp(struct sk_buff *skb,
nf_nat_sdp = rcu_dereference(nf_nat_sdp_hook); nf_nat_sdp = rcu_dereference(nf_nat_sdp_hook);
if (nf_nat_sdp && ct->status & IPS_NAT_MASK) if (nf_nat_sdp && ct->status & IPS_NAT_MASK)
ret = nf_nat_sdp(skb, ctinfo, exp, dptr, datalen); ret = nf_nat_sdp(skb, dptr, datalen, exp);
else { else {
if (nf_ct_expect_related(exp) != 0) if (nf_ct_expect_related(exp) != 0)
ret = NF_DROP; ret = NF_DROP;
...@@ -431,7 +427,7 @@ static int sip_help(struct sk_buff *skb, ...@@ -431,7 +427,7 @@ static int sip_help(struct sk_buff *skb,
nf_nat_sip = rcu_dereference(nf_nat_sip_hook); nf_nat_sip = rcu_dereference(nf_nat_sip_hook);
if (nf_nat_sip && ct->status & IPS_NAT_MASK) { if (nf_nat_sip && ct->status & IPS_NAT_MASK) {
if (!nf_nat_sip(skb, ctinfo, ct, &dptr, &datalen)) { if (!nf_nat_sip(skb, &dptr, &datalen)) {
ret = NF_DROP; ret = NF_DROP;
goto out; goto out;
} }
...@@ -467,8 +463,8 @@ static int sip_help(struct sk_buff *skb, ...@@ -467,8 +463,8 @@ static int sip_help(struct sk_buff *skb,
ret = NF_DROP; ret = NF_DROP;
goto out; goto out;
} }
ret = set_expected_rtp(skb, ct, ctinfo, &addr, ret = set_expected_rtp(skb, &dptr, &datalen,
htons(port), &dptr, &datalen); &addr, htons(port));
} }
} }
out: out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment