[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250107184724.56223-2-egyszeregy@freemail.hu>
Date: Tue, 7 Jan 2025 19:47:19 +0100
From: egyszeregy@...email.hu
To: fw@...len.de,
pablo@...filter.org,
lorenzo@...nel.org,
daniel@...earbox.net,
leitao@...ian.org,
amiculas@...co.com,
kadlec@...filter.org,
davem@...emloft.net,
dsahern@...nel.org,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com,
horms@...nel.org,
netfilter-devel@...r.kernel.org,
coreteam@...filter.org,
linux-kernel@...r.kernel.org,
netdev@...r.kernel.org
Cc: Benjamin Szőke <egyszeregy@...email.hu>
Subject: [PATCH 1/6] netfilter: x_tables: Format code of xt_*.c files.
From: Benjamin Szőke <egyszeregy@...email.hu>
Adjuste code style to be compatbile with checkpatch.pl checks in
the following files: xt_DSCP.c, xt_HL.c, xt_RATEEST.c, xt_TCPMSS.c
- Change to use u8, u16 and u32 types.
- Fix coding style of math operations and brackets.
Signed-off-by: Benjamin Szőke <egyszeregy@...email.hu>
---
net/netfilter/xt_DSCP.c | 9 ++++-----
net/netfilter/xt_HL.c | 3 +--
net/netfilter/xt_RATEEST.c | 1 +
net/netfilter/xt_TCPMSS.c | 26 ++++++++++++++------------
4 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/net/netfilter/xt_DSCP.c b/net/netfilter/xt_DSCP.c
index 90f24a6a26c5..a76701fd31ab 100644
--- a/net/netfilter/xt_DSCP.c
+++ b/net/netfilter/xt_DSCP.c
@@ -30,7 +30,7 @@ static unsigned int
dscp_tg(struct sk_buff *skb, const struct xt_action_param *par)
{
const struct xt_DSCP_info *dinfo = par->targinfo;
- u_int8_t dscp = ipv4_get_dsfield(ip_hdr(skb)) >> XT_DSCP_SHIFT;
+ u8 dscp = ipv4_get_dsfield(ip_hdr(skb)) >> XT_DSCP_SHIFT;
if (dscp != dinfo->dscp) {
if (skb_ensure_writable(skb, sizeof(struct iphdr)))
@@ -38,7 +38,6 @@ dscp_tg(struct sk_buff *skb, const struct xt_action_param *par)
ipv4_change_dsfield(ip_hdr(skb), XT_DSCP_ECN_MASK,
dinfo->dscp << XT_DSCP_SHIFT);
-
}
return XT_CONTINUE;
}
@@ -47,7 +46,7 @@ static unsigned int
dscp_tg6(struct sk_buff *skb, const struct xt_action_param *par)
{
const struct xt_DSCP_info *dinfo = par->targinfo;
- u_int8_t dscp = ipv6_get_dsfield(ipv6_hdr(skb)) >> XT_DSCP_SHIFT;
+ u8 dscp = ipv6_get_dsfield(ipv6_hdr(skb)) >> XT_DSCP_SHIFT;
if (dscp != dinfo->dscp) {
if (skb_ensure_writable(skb, sizeof(struct ipv6hdr)))
@@ -73,7 +72,7 @@ tos_tg(struct sk_buff *skb, const struct xt_action_param *par)
{
const struct xt_tos_target_info *info = par->targinfo;
struct iphdr *iph = ip_hdr(skb);
- u_int8_t orig, nv;
+ u8 orig, nv;
orig = ipv4_get_dsfield(iph);
nv = (orig & ~info->tos_mask) ^ info->tos_value;
@@ -93,7 +92,7 @@ tos_tg6(struct sk_buff *skb, const struct xt_action_param *par)
{
const struct xt_tos_target_info *info = par->targinfo;
struct ipv6hdr *iph = ipv6_hdr(skb);
- u_int8_t orig, nv;
+ u8 orig, nv;
orig = ipv6_get_dsfield(iph);
nv = (orig & ~info->tos_mask) ^ info->tos_value;
diff --git a/net/netfilter/xt_HL.c b/net/netfilter/xt_HL.c
index a847d7a7eacd..1e1b30b27fef 100644
--- a/net/netfilter/xt_HL.c
+++ b/net/netfilter/xt_HL.c
@@ -54,8 +54,7 @@ ttl_tg(struct sk_buff *skb, const struct xt_action_param *par)
}
if (new_ttl != iph->ttl) {
- csum_replace2(&iph->check, htons(iph->ttl << 8),
- htons(new_ttl << 8));
+ csum_replace2(&iph->check, htons(iph->ttl << 8), htons(new_ttl << 8));
iph->ttl = new_ttl;
}
diff --git a/net/netfilter/xt_RATEEST.c b/net/netfilter/xt_RATEEST.c
index a86bb0e4bb42..d56276b965fa 100644
--- a/net/netfilter/xt_RATEEST.c
+++ b/net/netfilter/xt_RATEEST.c
@@ -20,6 +20,7 @@
#define RATEEST_HSIZE 16
struct xt_rateest_net {
+ /* To synchronize concurrent synchronous rate estimator operations. */
struct mutex hash_lock;
struct hlist_head hash[RATEEST_HSIZE];
};
diff --git a/net/netfilter/xt_TCPMSS.c b/net/netfilter/xt_TCPMSS.c
index 3dc1320237c2..9944ca1eb950 100644
--- a/net/netfilter/xt_TCPMSS.c
+++ b/net/netfilter/xt_TCPMSS.c
@@ -31,13 +31,13 @@ MODULE_ALIAS("ipt_TCPMSS");
MODULE_ALIAS("ip6t_TCPMSS");
static inline unsigned int
-optlen(const u_int8_t *opt, unsigned int offset)
+optlen(const u8 *opt, unsigned int offset)
{
/* Beware zero-length options: make finite progress */
- if (opt[offset] <= TCPOPT_NOP || opt[offset+1] == 0)
+ if (opt[offset] <= TCPOPT_NOP || opt[offset + 1] == 0)
return 1;
else
- return opt[offset+1];
+ return opt[offset + 1];
}
static u_int32_t tcpmss_reverse_mtu(struct net *net,
@@ -46,10 +46,11 @@ static u_int32_t tcpmss_reverse_mtu(struct net *net,
{
struct flowi fl;
struct rtable *rt = NULL;
- u_int32_t mtu = ~0U;
+ u32 mtu = ~0U;
if (family == PF_INET) {
struct flowi4 *fl4 = &fl.u.ip4;
+
memset(fl4, 0, sizeof(*fl4));
fl4->daddr = ip_hdr(skb)->saddr;
} else {
@@ -60,7 +61,7 @@ static u_int32_t tcpmss_reverse_mtu(struct net *net,
}
nf_route(net, (struct dst_entry **)&rt, &fl, false, family);
- if (rt != NULL) {
+ if (rt) {
mtu = dst_mtu(&rt->dst);
dst_release(&rt->dst);
}
@@ -110,15 +111,16 @@ tcpmss_mangle_packet(struct sk_buff *skb,
return -1;
}
newmss = min_mtu - minlen;
- } else
+ } else {
newmss = info->mss;
+ }
opt = (u_int8_t *)tcph;
for (i = sizeof(struct tcphdr); i <= tcp_hdrlen - TCPOLEN_MSS; i += optlen(opt, i)) {
- if (opt[i] == TCPOPT_MSS && opt[i+1] == TCPOLEN_MSS) {
- u_int16_t oldmss;
+ if (opt[i] == TCPOPT_MSS && opt[i + 1] == TCPOLEN_MSS) {
+ u16 oldmss;
- oldmss = (opt[i+2] << 8) | opt[i+3];
+ oldmss = (opt[i + 2] << 8) | opt[i + 3];
/* Never increase MSS, even when setting it, as
* doing so results in problems for hosts that rely
@@ -127,8 +129,8 @@ tcpmss_mangle_packet(struct sk_buff *skb,
if (oldmss <= newmss)
return 0;
- opt[i+2] = (newmss & 0xff00) >> 8;
- opt[i+3] = newmss & 0x00ff;
+ opt[i + 2] = (newmss & 0xff00) >> 8;
+ opt[i + 3] = newmss & 0x00ff;
inet_proto_csum_replace2(&tcph->check, skb,
htons(oldmss), htons(newmss),
@@ -186,7 +188,7 @@ tcpmss_mangle_packet(struct sk_buff *skb,
inet_proto_csum_replace4(&tcph->check, skb, 0, *((__be32 *)opt), false);
oldval = ((__be16 *)tcph)[6];
- tcph->doff += TCPOLEN_MSS/4;
+ tcph->doff += TCPOLEN_MSS / 4;
inet_proto_csum_replace2(&tcph->check, skb,
oldval, ((__be16 *)tcph)[6], false);
return TCPOLEN_MSS;
--
2.43.5
Powered by blists - more mailing lists