* [PATCH net-next 1/5] net/ipv4: make use of the helper macro LIST_HEAD()
2024-08-27 10:04 [PATCH net-next 0/5] make use of the helper macro LIST_HEAD() Hongbo Li
@ 2024-08-27 10:04 ` Hongbo Li
2024-08-27 10:04 ` [PATCH net-next 2/5] net/tipc: " Hongbo Li
` (3 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: Hongbo Li @ 2024-08-27 10:04 UTC (permalink / raw)
To: davem, dsahern, edumazet, kuba, pabeni, jmaloy, ying.xue, pablo,
kadlec
Cc: netdev, netfilter-devel, lihongbo22
list_head can be initialized automatically with LIST_HEAD()
instead of calling INIT_LIST_HEAD(). Here we can simplify
the code.
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
net/ipv4/ip_input.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index d6fbcbd2358a..b6e7d4921309 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -596,9 +596,8 @@ static void ip_list_rcv_finish(struct net *net, struct sock *sk,
{
struct sk_buff *skb, *next, *hint = NULL;
struct dst_entry *curr_dst = NULL;
- struct list_head sublist;
+ LIST_HEAD(sublist);
- INIT_LIST_HEAD(&sublist);
list_for_each_entry_safe(skb, next, head, list) {
struct net_device *dev = skb->dev;
struct dst_entry *dst;
@@ -646,9 +645,8 @@ void ip_list_rcv(struct list_head *head, struct packet_type *pt,
struct net_device *curr_dev = NULL;
struct net *curr_net = NULL;
struct sk_buff *skb, *next;
- struct list_head sublist;
+ LIST_HEAD(sublist);
- INIT_LIST_HEAD(&sublist);
list_for_each_entry_safe(skb, next, head, list) {
struct net_device *dev = skb->dev;
struct net *net = dev_net(dev);
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH net-next 2/5] net/tipc: make use of the helper macro LIST_HEAD()
2024-08-27 10:04 [PATCH net-next 0/5] make use of the helper macro LIST_HEAD() Hongbo Li
2024-08-27 10:04 ` [PATCH net-next 1/5] net/ipv4: " Hongbo Li
@ 2024-08-27 10:04 ` Hongbo Li
2024-08-27 16:57 ` Simon Horman
2024-08-27 10:04 ` [PATCH net-next 3/5] net/netfilter: " Hongbo Li
` (2 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Hongbo Li @ 2024-08-27 10:04 UTC (permalink / raw)
To: davem, dsahern, edumazet, kuba, pabeni, jmaloy, ying.xue, pablo,
kadlec
Cc: netdev, netfilter-devel, lihongbo22
list_head can be initialized automatically with LIST_HEAD()
instead of calling INIT_LIST_HEAD(). Here we can simplify
the code.
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
net/tipc/socket.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 1a0cd06f0eae..9d30e362392c 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -1009,12 +1009,11 @@ static int tipc_send_group_anycast(struct socket *sock, struct msghdr *m,
struct tipc_member *mbr = NULL;
struct net *net = sock_net(sk);
u32 node, port, exclude;
- struct list_head dsts;
int lookups = 0;
int dstcnt, rc;
bool cong;
+ LIST_HEAD(dsts);
- INIT_LIST_HEAD(&dsts);
ua->sa.type = msg_nametype(hdr);
ua->scope = msg_lookup_scope(hdr);
@@ -1161,10 +1160,9 @@ static int tipc_send_group_mcast(struct socket *sock, struct msghdr *m,
struct tipc_group *grp = tsk->group;
struct tipc_msg *hdr = &tsk->phdr;
struct net *net = sock_net(sk);
- struct list_head dsts;
u32 dstcnt, exclude;
+ LIST_HEAD(dsts);
- INIT_LIST_HEAD(&dsts);
ua->sa.type = msg_nametype(hdr);
ua->scope = msg_lookup_scope(hdr);
exclude = tipc_group_exclude(grp);
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH net-next 2/5] net/tipc: make use of the helper macro LIST_HEAD()
2024-08-27 10:04 ` [PATCH net-next 2/5] net/tipc: " Hongbo Li
@ 2024-08-27 16:57 ` Simon Horman
2024-08-30 1:17 ` Hongbo Li
0 siblings, 1 reply; 11+ messages in thread
From: Simon Horman @ 2024-08-27 16:57 UTC (permalink / raw)
To: Hongbo Li
Cc: davem, dsahern, edumazet, kuba, pabeni, jmaloy, ying.xue, pablo,
kadlec, netdev, netfilter-devel
On Tue, Aug 27, 2024 at 06:04:04PM +0800, Hongbo Li wrote:
> list_head can be initialized automatically with LIST_HEAD()
> instead of calling INIT_LIST_HEAD(). Here we can simplify
> the code.
>
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
> ---
> net/tipc/socket.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/net/tipc/socket.c b/net/tipc/socket.c
> index 1a0cd06f0eae..9d30e362392c 100644
> --- a/net/tipc/socket.c
> +++ b/net/tipc/socket.c
> @@ -1009,12 +1009,11 @@ static int tipc_send_group_anycast(struct socket *sock, struct msghdr *m,
> struct tipc_member *mbr = NULL;
> struct net *net = sock_net(sk);
> u32 node, port, exclude;
> - struct list_head dsts;
> int lookups = 0;
> int dstcnt, rc;
> bool cong;
> + LIST_HEAD(dsts);
nit: Please place this new line where the old dsts line was,
in order to preserve, within the context of this hunk,
reverse xmas tree order - longest line to shortest -
for local variable declarations.
>
> - INIT_LIST_HEAD(&dsts);
> ua->sa.type = msg_nametype(hdr);
> ua->scope = msg_lookup_scope(hdr);
>
> @@ -1161,10 +1160,9 @@ static int tipc_send_group_mcast(struct socket *sock, struct msghdr *m,
> struct tipc_group *grp = tsk->group;
> struct tipc_msg *hdr = &tsk->phdr;
> struct net *net = sock_net(sk);
> - struct list_head dsts;
> u32 dstcnt, exclude;
> + LIST_HEAD(dsts);
>
> - INIT_LIST_HEAD(&dsts);
> ua->sa.type = msg_nametype(hdr);
> ua->scope = msg_lookup_scope(hdr);
> exclude = tipc_group_exclude(grp);
--
pw-bot: cr
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH net-next 2/5] net/tipc: make use of the helper macro LIST_HEAD()
2024-08-27 16:57 ` Simon Horman
@ 2024-08-30 1:17 ` Hongbo Li
0 siblings, 0 replies; 11+ messages in thread
From: Hongbo Li @ 2024-08-30 1:17 UTC (permalink / raw)
To: Simon Horman
Cc: davem, dsahern, edumazet, kuba, pabeni, jmaloy, ying.xue, pablo,
kadlec, netdev, netfilter-devel
On 2024/8/28 0:57, Simon Horman wrote:
> On Tue, Aug 27, 2024 at 06:04:04PM +0800, Hongbo Li wrote:
>> list_head can be initialized automatically with LIST_HEAD()
>> instead of calling INIT_LIST_HEAD(). Here we can simplify
>> the code.
>>
>> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
>> ---
>> net/tipc/socket.c | 6 ++----
>> 1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/net/tipc/socket.c b/net/tipc/socket.c
>> index 1a0cd06f0eae..9d30e362392c 100644
>> --- a/net/tipc/socket.c
>> +++ b/net/tipc/socket.c
>> @@ -1009,12 +1009,11 @@ static int tipc_send_group_anycast(struct socket *sock, struct msghdr *m,
>> struct tipc_member *mbr = NULL;
>> struct net *net = sock_net(sk);
>> u32 node, port, exclude;
>> - struct list_head dsts;
>> int lookups = 0;
>> int dstcnt, rc;
>> bool cong;
>> + LIST_HEAD(dsts);
>
> nit: Please place this new line where the old dsts line was,
> in order to preserve, within the context of this hunk,
> reverse xmas tree order - longest line to shortest -
ok, I've learned, the reverse xmas tree order. Thank you!
Thanks,
Hongbo
> for local variable declarations.
>
>>
>> - INIT_LIST_HEAD(&dsts);
>> ua->sa.type = msg_nametype(hdr);
>> ua->scope = msg_lookup_scope(hdr);
>>
>> @@ -1161,10 +1160,9 @@ static int tipc_send_group_mcast(struct socket *sock, struct msghdr *m,
>> struct tipc_group *grp = tsk->group;
>> struct tipc_msg *hdr = &tsk->phdr;
>> struct net *net = sock_net(sk);
>> - struct list_head dsts;
>> u32 dstcnt, exclude;
>> + LIST_HEAD(dsts);
>>
>> - INIT_LIST_HEAD(&dsts);
>> ua->sa.type = msg_nametype(hdr);
>> ua->scope = msg_lookup_scope(hdr);
>> exclude = tipc_group_exclude(grp);
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH net-next 3/5] net/netfilter: make use of the helper macro LIST_HEAD()
2024-08-27 10:04 [PATCH net-next 0/5] make use of the helper macro LIST_HEAD() Hongbo Li
2024-08-27 10:04 ` [PATCH net-next 1/5] net/ipv4: " Hongbo Li
2024-08-27 10:04 ` [PATCH net-next 2/5] net/tipc: " Hongbo Li
@ 2024-08-27 10:04 ` Hongbo Li
2024-08-27 16:15 ` Pablo Neira Ayuso
2024-08-27 10:04 ` [PATCH net-next 4/5] net/ipv6: " Hongbo Li
2024-08-27 10:04 ` [PATCH net-next 5/5] net/core: " Hongbo Li
4 siblings, 1 reply; 11+ messages in thread
From: Hongbo Li @ 2024-08-27 10:04 UTC (permalink / raw)
To: davem, dsahern, edumazet, kuba, pabeni, jmaloy, ying.xue, pablo,
kadlec
Cc: netdev, netfilter-devel, lihongbo22
list_head can be initialized automatically with LIST_HEAD()
instead of calling INIT_LIST_HEAD(). Here we can simplify
the code.
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
net/netfilter/core.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index b00fc285b334..93642fcd379c 100644
--- a/net/netfilter/core.c
+++ b/net/netfilter/core.c
@@ -655,10 +655,8 @@ void nf_hook_slow_list(struct list_head *head, struct nf_hook_state *state,
const struct nf_hook_entries *e)
{
struct sk_buff *skb, *next;
- struct list_head sublist;
int ret;
-
- INIT_LIST_HEAD(&sublist);
+ LIST_HEAD(sublist);
list_for_each_entry_safe(skb, next, head, list) {
skb_list_del_init(skb);
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH net-next 3/5] net/netfilter: make use of the helper macro LIST_HEAD()
2024-08-27 10:04 ` [PATCH net-next 3/5] net/netfilter: " Hongbo Li
@ 2024-08-27 16:15 ` Pablo Neira Ayuso
2024-08-28 1:35 ` Hongbo Li
0 siblings, 1 reply; 11+ messages in thread
From: Pablo Neira Ayuso @ 2024-08-27 16:15 UTC (permalink / raw)
To: Hongbo Li
Cc: davem, dsahern, edumazet, kuba, pabeni, jmaloy, ying.xue, kadlec,
netdev, netfilter-devel
Hi,
On Tue, Aug 27, 2024 at 06:04:05PM +0800, Hongbo Li wrote:
> list_head can be initialized automatically with LIST_HEAD()
> instead of calling INIT_LIST_HEAD(). Here we can simplify
> the code.
>
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
> ---
> net/netfilter/core.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/net/netfilter/core.c b/net/netfilter/core.c
> index b00fc285b334..93642fcd379c 100644
> --- a/net/netfilter/core.c
> +++ b/net/netfilter/core.c
> @@ -655,10 +655,8 @@ void nf_hook_slow_list(struct list_head *head, struct nf_hook_state *state,
> const struct nf_hook_entries *e)
> {
> struct sk_buff *skb, *next;
> - struct list_head sublist;
> int ret;
> -
> - INIT_LIST_HEAD(&sublist);
> + LIST_HEAD(sublist);
comestic:
struct sk_buff *skb, *next;
LIST_HEAD(sublist); <- here
int ret;
I think this should be included in the variable declaration area at
the beginning of this function.
> list_for_each_entry_safe(skb, next, head, list) {
> skb_list_del_init(skb);
> --
> 2.34.1
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH net-next 3/5] net/netfilter: make use of the helper macro LIST_HEAD()
2024-08-27 16:15 ` Pablo Neira Ayuso
@ 2024-08-28 1:35 ` Hongbo Li
2024-08-28 6:52 ` Pablo Neira Ayuso
0 siblings, 1 reply; 11+ messages in thread
From: Hongbo Li @ 2024-08-28 1:35 UTC (permalink / raw)
To: Pablo Neira Ayuso
Cc: davem, dsahern, edumazet, kuba, pabeni, jmaloy, ying.xue, kadlec,
netdev, netfilter-devel
On 2024/8/28 0:15, Pablo Neira Ayuso wrote:
> Hi,
>
> On Tue, Aug 27, 2024 at 06:04:05PM +0800, Hongbo Li wrote:
>> list_head can be initialized automatically with LIST_HEAD()
>> instead of calling INIT_LIST_HEAD(). Here we can simplify
>> the code.
>>
>> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
>> ---
>> net/netfilter/core.c | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/net/netfilter/core.c b/net/netfilter/core.c
>> index b00fc285b334..93642fcd379c 100644
>> --- a/net/netfilter/core.c
>> +++ b/net/netfilter/core.c
>> @@ -655,10 +655,8 @@ void nf_hook_slow_list(struct list_head *head, struct nf_hook_state *state,
>> const struct nf_hook_entries *e)
>> {
>> struct sk_buff *skb, *next;
>> - struct list_head sublist;
>> int ret;
>> -
>> - INIT_LIST_HEAD(&sublist);
>> + LIST_HEAD(sublist);
>
> comestic:
>
> struct sk_buff *skb, *next;
> LIST_HEAD(sublist); <- here
> int ret;
>
> I think this should be included in the variable declaration area at
> the beginning of this function.
It is in the variable declaration area just after ret (with a blank line
before list_for_each_entry_safe).
Thanks,
Hongbo
>
>> list_for_each_entry_safe(skb, next, head, list) {
>> skb_list_del_init(skb);
>> --
>> 2.34.1
>>
>>
>
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH net-next 3/5] net/netfilter: make use of the helper macro LIST_HEAD()
2024-08-28 1:35 ` Hongbo Li
@ 2024-08-28 6:52 ` Pablo Neira Ayuso
0 siblings, 0 replies; 11+ messages in thread
From: Pablo Neira Ayuso @ 2024-08-28 6:52 UTC (permalink / raw)
To: Hongbo Li
Cc: davem, dsahern, edumazet, kuba, pabeni, jmaloy, ying.xue, kadlec,
netdev, netfilter-devel
On Wed, Aug 28, 2024 at 09:35:35AM +0800, Hongbo Li wrote:
>
>
> On 2024/8/28 0:15, Pablo Neira Ayuso wrote:
> > Hi,
> >
> > On Tue, Aug 27, 2024 at 06:04:05PM +0800, Hongbo Li wrote:
> > > list_head can be initialized automatically with LIST_HEAD()
> > > instead of calling INIT_LIST_HEAD(). Here we can simplify
> > > the code.
> > >
> > > Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
> > > ---
> > > net/netfilter/core.c | 4 +---
> > > 1 file changed, 1 insertion(+), 3 deletions(-)
> > >
> > > diff --git a/net/netfilter/core.c b/net/netfilter/core.c
> > > index b00fc285b334..93642fcd379c 100644
> > > --- a/net/netfilter/core.c
> > > +++ b/net/netfilter/core.c
> > > @@ -655,10 +655,8 @@ void nf_hook_slow_list(struct list_head *head, struct nf_hook_state *state,
> > > const struct nf_hook_entries *e)
> > > {
> > > struct sk_buff *skb, *next;
> > > - struct list_head sublist;
> > > int ret;
> > > -
> > > - INIT_LIST_HEAD(&sublist);
> > > + LIST_HEAD(sublist);
> >
> > comestic:
> >
> > struct sk_buff *skb, *next;
> > LIST_HEAD(sublist); <- here
> > int ret;
> >
> > I think this should be included in the variable declaration area at
> > the beginning of this function.
>
> It is in the variable declaration area just after ret (with a blank line
> before list_for_each_entry_safe).
Indeed. It is reverse xmas tree what I was missing then.
Thanks.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH net-next 4/5] net/ipv6: make use of the helper macro LIST_HEAD()
2024-08-27 10:04 [PATCH net-next 0/5] make use of the helper macro LIST_HEAD() Hongbo Li
` (2 preceding siblings ...)
2024-08-27 10:04 ` [PATCH net-next 3/5] net/netfilter: " Hongbo Li
@ 2024-08-27 10:04 ` Hongbo Li
2024-08-27 10:04 ` [PATCH net-next 5/5] net/core: " Hongbo Li
4 siblings, 0 replies; 11+ messages in thread
From: Hongbo Li @ 2024-08-27 10:04 UTC (permalink / raw)
To: davem, dsahern, edumazet, kuba, pabeni, jmaloy, ying.xue, pablo,
kadlec
Cc: netdev, netfilter-devel, lihongbo22
list_head can be initialized automatically with LIST_HEAD()
instead of calling INIT_LIST_HEAD(). Here we can simplify
the code.
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
net/ipv6/ip6_input.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index 133610a49da6..70c0e16c0ae6 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -111,9 +111,8 @@ static void ip6_list_rcv_finish(struct net *net, struct sock *sk,
{
struct sk_buff *skb, *next, *hint = NULL;
struct dst_entry *curr_dst = NULL;
- struct list_head sublist;
+ LIST_HEAD(sublist);
- INIT_LIST_HEAD(&sublist);
list_for_each_entry_safe(skb, next, head, list) {
struct dst_entry *dst;
@@ -327,9 +326,8 @@ void ipv6_list_rcv(struct list_head *head, struct packet_type *pt,
struct net_device *curr_dev = NULL;
struct net *curr_net = NULL;
struct sk_buff *skb, *next;
- struct list_head sublist;
+ LIST_HEAD(sublist);
- INIT_LIST_HEAD(&sublist);
list_for_each_entry_safe(skb, next, head, list) {
struct net_device *dev = skb->dev;
struct net *net = dev_net(dev);
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH net-next 5/5] net/core: make use of the helper macro LIST_HEAD()
2024-08-27 10:04 [PATCH net-next 0/5] make use of the helper macro LIST_HEAD() Hongbo Li
` (3 preceding siblings ...)
2024-08-27 10:04 ` [PATCH net-next 4/5] net/ipv6: " Hongbo Li
@ 2024-08-27 10:04 ` Hongbo Li
4 siblings, 0 replies; 11+ messages in thread
From: Hongbo Li @ 2024-08-27 10:04 UTC (permalink / raw)
To: davem, dsahern, edumazet, kuba, pabeni, jmaloy, ying.xue, pablo,
kadlec
Cc: netdev, netfilter-devel, lihongbo22
list_head can be initialized automatically with LIST_HEAD()
instead of calling INIT_LIST_HEAD(). Here we can simplify
the code.
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
net/core/dev.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 0d0b983a6c21..b0b660c90cb9 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5726,10 +5726,9 @@ static void __netif_receive_skb_list_core(struct list_head *head, bool pfmemallo
struct packet_type *pt_curr = NULL;
/* Current (common) orig_dev of sublist */
struct net_device *od_curr = NULL;
- struct list_head sublist;
struct sk_buff *skb, *next;
+ LIST_HEAD(sublist);
- INIT_LIST_HEAD(&sublist);
list_for_each_entry_safe(skb, next, head, list) {
struct net_device *orig_dev = skb->dev;
struct packet_type *pt_prev = NULL;
@@ -5867,9 +5866,8 @@ static int netif_receive_skb_internal(struct sk_buff *skb)
void netif_receive_skb_list_internal(struct list_head *head)
{
struct sk_buff *skb, *next;
- struct list_head sublist;
+ LIST_HEAD(sublist);
- INIT_LIST_HEAD(&sublist);
list_for_each_entry_safe(skb, next, head, list) {
net_timestamp_check(READ_ONCE(net_hotdata.tstamp_prequeue),
skb);
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread