mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-07 05:05:12 +02:00
psd: avoid shadowing of function
ip_hdr and tcp_hdr are actually functions. Because we need them means they must not be shadowed by variables.
This commit is contained in:
@@ -101,8 +101,8 @@ static inline int hashfunc(struct in_addr addr)
|
|||||||
static bool
|
static bool
|
||||||
xt_psd_match(const struct sk_buff *pskb, const struct xt_match_param *match)
|
xt_psd_match(const struct sk_buff *pskb, const struct xt_match_param *match)
|
||||||
{
|
{
|
||||||
struct iphdr *ip_hdr;
|
struct iphdr *iph;
|
||||||
struct tcphdr *tcp_hdr;
|
struct tcphdr *tcph;
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
u_int16_t src_port,dest_port;
|
u_int16_t src_port,dest_port;
|
||||||
u_int8_t tcp_flags, proto;
|
u_int8_t tcp_flags, proto;
|
||||||
@@ -113,16 +113,16 @@ xt_psd_match(const struct sk_buff *pskb, const struct xt_match_param *match)
|
|||||||
const struct xt_psd_info *psdinfo = match->matchinfo;
|
const struct xt_psd_info *psdinfo = match->matchinfo;
|
||||||
|
|
||||||
/* IP header */
|
/* IP header */
|
||||||
ip_hdr = (struct iphdr*) pskb->network_header;
|
iph = (struct iphdr*) pskb->network_header;
|
||||||
|
|
||||||
/* Sanity check */
|
/* Sanity check */
|
||||||
if (ntohs(ip_hdr->frag_off) & IP_OFFSET) {
|
if (ntohs(iph->frag_off) & IP_OFFSET) {
|
||||||
pr_debug(KBUILD_MODNAME "sanity check failed\n");
|
pr_debug(KBUILD_MODNAME "sanity check failed\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TCP or UDP ? */
|
/* TCP or UDP ? */
|
||||||
proto = ip_hdr->protocol;
|
proto = iph->protocol;
|
||||||
|
|
||||||
if (proto != IPPROTO_TCP && proto != IPPROTO_UDP) {
|
if (proto != IPPROTO_TCP && proto != IPPROTO_UDP) {
|
||||||
pr_debug(KBUILD_MODNAME "protocol not supported\n");
|
pr_debug(KBUILD_MODNAME "protocol not supported\n");
|
||||||
@@ -131,16 +131,16 @@ xt_psd_match(const struct sk_buff *pskb, const struct xt_match_param *match)
|
|||||||
|
|
||||||
/* Get the source address, source & destination ports, and TCP flags */
|
/* Get the source address, source & destination ports, and TCP flags */
|
||||||
|
|
||||||
addr.s_addr = ip_hdr->saddr;
|
addr.s_addr = iph->saddr;
|
||||||
|
|
||||||
tcp_hdr = (struct tcphdr*)((u_int32_t *)ip_hdr + ip_hdr->ihl);
|
tcph = (struct tcphdr*)((u_int32_t *)iph + iph->ihl);
|
||||||
|
|
||||||
/* Yep, it<69>s dirty */
|
/* Yep, it<69>s dirty */
|
||||||
src_port = tcp_hdr->source;
|
src_port = tcph->source;
|
||||||
dest_port = tcp_hdr->dest;
|
dest_port = tcph->dest;
|
||||||
|
|
||||||
if (proto == IPPROTO_TCP) {
|
if (proto == IPPROTO_TCP) {
|
||||||
tcp_flags = *((u_int8_t*)tcp_hdr + 13);
|
tcp_flags = *((u_int8_t*)tcph + 13);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tcp_flags = 0x00;
|
tcp_flags = 0x00;
|
||||||
@@ -186,7 +186,7 @@ xt_psd_match(const struct sk_buff *pskb, const struct xt_match_param *match)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* TCP/ACK and/or TCP/RST to a new port? This could be an outgoing connection. */
|
/* TCP/ACK and/or TCP/RST to a new port? This could be an outgoing connection. */
|
||||||
if (proto == IPPROTO_TCP && (tcp_hdr->ack || tcp_hdr->rst))
|
if (proto == IPPROTO_TCP && (tcph->ack || tcph->rst))
|
||||||
goto out_no_match;
|
goto out_no_match;
|
||||||
|
|
||||||
/* Packet to a new port, and not TCP/ACK: update the timestamp */
|
/* Packet to a new port, and not TCP/ACK: update the timestamp */
|
||||||
@@ -197,13 +197,13 @@ xt_psd_match(const struct sk_buff *pskb, const struct xt_match_param *match)
|
|||||||
goto out_match;
|
goto out_match;
|
||||||
|
|
||||||
/* Specify if destination address, source port, TOS or TTL are not fixed */
|
/* Specify if destination address, source port, TOS or TTL are not fixed */
|
||||||
if (curr->dest_addr.s_addr != ip_hdr->daddr)
|
if (curr->dest_addr.s_addr != iph->daddr)
|
||||||
curr->flags |= HF_DADDR_CHANGING;
|
curr->flags |= HF_DADDR_CHANGING;
|
||||||
if (curr->src_port != src_port)
|
if (curr->src_port != src_port)
|
||||||
curr->flags |= HF_SPORT_CHANGING;
|
curr->flags |= HF_SPORT_CHANGING;
|
||||||
if (curr->tos != ip_hdr->tos)
|
if (curr->tos != iph->tos)
|
||||||
curr->flags |= HF_TOS_CHANGING;
|
curr->flags |= HF_TOS_CHANGING;
|
||||||
if (curr->ttl != ip_hdr->ttl)
|
if (curr->ttl != iph->ttl)
|
||||||
curr->flags |= HF_TTL_CHANGING;
|
curr->flags |= HF_TTL_CHANGING;
|
||||||
|
|
||||||
/* Update the total weight */
|
/* Update the total weight */
|
||||||
@@ -239,7 +239,7 @@ xt_psd_match(const struct sk_buff *pskb, const struct xt_match_param *match)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* We don't need an ACK from a new source address */
|
/* We don't need an ACK from a new source address */
|
||||||
if (proto == IPPROTO_TCP && tcp_hdr->ack)
|
if (proto == IPPROTO_TCP && tcph->ack)
|
||||||
goto out_no_match;
|
goto out_no_match;
|
||||||
|
|
||||||
/* Got too many source addresses with the same hash value? Then remove the
|
/* Got too many source addresses with the same hash value? Then remove the
|
||||||
@@ -283,7 +283,7 @@ xt_psd_match(const struct sk_buff *pskb, const struct xt_match_param *match)
|
|||||||
/* And fill in the fields */
|
/* And fill in the fields */
|
||||||
curr->timestamp = now;
|
curr->timestamp = now;
|
||||||
curr->src_addr = addr;
|
curr->src_addr = addr;
|
||||||
curr->dest_addr.s_addr = ip_hdr->daddr;
|
curr->dest_addr.s_addr = iph->daddr;
|
||||||
curr->src_port = src_port;
|
curr->src_port = src_port;
|
||||||
curr->count = 1;
|
curr->count = 1;
|
||||||
curr->weight = (ntohs(dest_port) < 1024) ? psdinfo->lo_ports_weight : psdinfo->hi_ports_weight;
|
curr->weight = (ntohs(dest_port) < 1024) ? psdinfo->lo_ports_weight : psdinfo->hi_ports_weight;
|
||||||
@@ -291,8 +291,8 @@ xt_psd_match(const struct sk_buff *pskb, const struct xt_match_param *match)
|
|||||||
curr->ports[0].proto = proto;
|
curr->ports[0].proto = proto;
|
||||||
curr->ports[0].and_flags = tcp_flags;
|
curr->ports[0].and_flags = tcp_flags;
|
||||||
curr->ports[0].or_flags = tcp_flags;
|
curr->ports[0].or_flags = tcp_flags;
|
||||||
curr->tos = ip_hdr->tos;
|
curr->tos = iph->tos;
|
||||||
curr->ttl = ip_hdr->ttl;
|
curr->ttl = iph->ttl;
|
||||||
|
|
||||||
out_no_match:
|
out_no_match:
|
||||||
spin_unlock(&state.lock);
|
spin_unlock(&state.lock);
|
||||||
|
Reference in New Issue
Block a user