]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
fix up raw-use-more-conventional-iterators.patch for older kernels
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Jul 2026 09:27:27 +0000 (11:27 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Jul 2026 09:27:27 +0000 (11:27 +0200)
queue-5.10/raw-use-more-conventional-iterators.patch
queue-5.15/raw-use-more-conventional-iterators.patch

index 9e0f6c209d93df4d370cc2d6b19069000afe37c7..7bef1d7492848322172e72725d2d48c9b5140511 100644 (file)
@@ -16,15 +16,13 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
 Stable-dep-of: 440e274da4d1 ("net: ipv6: fix dif and sdif mismatch in raw6_icmp_error")
 Signed-off-by: Sasha Levin <sashal@kernel.org>
 ---
- include/net/raw.h   |   5 +--
- include/net/rawv6.h |   6 +--
- net/ipv4/raw.c      |  93 ++++++++++++++-------------------------
- net/ipv4/raw_diag.c |  33 +++++++-------
- net/ipv6/raw.c      | 105 ++++++++++++++++----------------------------
+ include/net/raw.h   |    5 +-
+ include/net/rawv6.h |    6 +--
+ net/ipv4/raw.c      |   95 +++++++++++++++++------------------------------
+ net/ipv4/raw_diag.c |   33 ++++++++--------
+ net/ipv6/raw.c      |  103 ++++++++++++++++++----------------------------------
  5 files changed, 92 insertions(+), 150 deletions(-)
 
-diff --git a/include/net/raw.h b/include/net/raw.h
-index c51a635671a73d..6324965779ec6a 100644
 --- a/include/net/raw.h
 +++ b/include/net/raw.h
 @@ -20,9 +20,8 @@
@@ -39,8 +37,6 @@ index c51a635671a73d..6324965779ec6a 100644
  
  int raw_abort(struct sock *sk, int err);
  void raw_icmp_error(struct sk_buff *, int, u32);
-diff --git a/include/net/rawv6.h b/include/net/rawv6.h
-index 53d86b6055e8cc..c48c1298699a04 100644
 --- a/include/net/rawv6.h
 +++ b/include/net/rawv6.h
 @@ -5,9 +5,9 @@
@@ -56,8 +52,6 @@ index 53d86b6055e8cc..c48c1298699a04 100644
  
  int raw_abort(struct sock *sk, int err);
  
-diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
-index 2d14d9aabc0b3b..3ce0ff77ef3a61 100644
 --- a/net/ipv4/raw.c
 +++ b/net/ipv4/raw.c
 @@ -117,24 +117,19 @@ void raw_unhash_sk(struct sock *sk)
@@ -67,9 +61,7 @@ index 2d14d9aabc0b3b..3ce0ff77ef3a61 100644
 -struct sock *__raw_v4_lookup(struct net *net, struct sock *sk,
 -                           unsigned short num, __be32 raddr, __be32 laddr,
 -                           int dif, int sdif)
-+bool raw_v4_match(struct net *net, struct sock *sk, unsigned short num,
-+                __be32 raddr, __be32 laddr, int dif, int sdif)
- {
+-{
 -      sk_for_each_from(sk) {
 -              struct inet_sock *inet = inet_sk(sk);
 -
@@ -82,6 +74,9 @@ index 2d14d9aabc0b3b..3ce0ff77ef3a61 100644
 -      sk = NULL;
 -found:
 -      return sk;
++bool raw_v4_match(struct net *net, struct sock *sk, unsigned short num,
++                __be32 raddr, __be32 laddr, int dif, int sdif)
++{
 +      struct inet_sock *inet = inet_sk(sk);
 +
 +      if (net_eq(sock_net(sk), net) && inet->inet_num == num  &&
@@ -96,7 +91,7 @@ index 2d14d9aabc0b3b..3ce0ff77ef3a61 100644
  
  /*
   *    0 - deliver
-@@ -168,23 +163,21 @@ static int icmp_filter(const struct sock *sk, const struct sk_buff *skb)
+@@ -168,23 +163,21 @@ static int icmp_filter(const struct sock
   */
  static int raw_v4_input(struct sk_buff *skb, const struct iphdr *iph, int hash)
  {
@@ -128,7 +123,7 @@ index 2d14d9aabc0b3b..3ce0ff77ef3a61 100644
                delivered = 1;
                if ((iph->protocol != IPPROTO_ICMP || !icmp_filter(sk, skb)) &&
                    ip_mc_sf_allow(sk, iph->daddr, iph->saddr,
-@@ -195,31 +188,16 @@ static int raw_v4_input(struct sk_buff *skb, const struct iphdr *iph, int hash)
+@@ -195,31 +188,16 @@ static int raw_v4_input(struct sk_buff *
                        if (clone)
                                raw_rcv(sk, clone);
                }
@@ -162,13 +157,13 @@ index 2d14d9aabc0b3b..3ce0ff77ef3a61 100644
  }
  
  static void raw_err(struct sock *sk, struct sk_buff *skb, u32 info)
-@@ -286,29 +264,24 @@ static void raw_err(struct sock *sk, struct sk_buff *skb, u32 info)
+@@ -286,29 +264,24 @@ static void raw_err(struct sock *sk, str
  
  void raw_icmp_error(struct sk_buff *skb, int protocol, u32 info)
  {
 -      int hash;
 -      struct sock *raw_sk;
-+      struct net *net = dev_net(skb->dev);;
++      struct net *net = dev_net(skb->dev);
 +      int dif = skb->dev->ifindex;
 +      int sdif = inet_sdif(skb);
 +      struct hlist_head *head;
@@ -204,11 +199,9 @@ index 2d14d9aabc0b3b..3ce0ff77ef3a61 100644
        }
        read_unlock(&raw_v4_hashinfo.lock);
  }
-diff --git a/net/ipv4/raw_diag.c b/net/ipv4/raw_diag.c
-index ccacbde30a2c50..b6d92dc7b051d1 100644
 --- a/net/ipv4/raw_diag.c
 +++ b/net/ipv4/raw_diag.c
-@@ -34,31 +34,30 @@ raw_get_hashinfo(const struct inet_diag_req_v2 *r)
+@@ -34,31 +34,30 @@ raw_get_hashinfo(const struct inet_diag_
   * use helper to figure it out.
   */
  
@@ -252,7 +245,7 @@ index ccacbde30a2c50..b6d92dc7b051d1 100644
        int slot;
  
        if (IS_ERR(hashinfo))
-@@ -66,9 +65,8 @@ static struct sock *raw_sock_get(struct net *net, const struct inet_diag_req_v2
+@@ -66,9 +65,8 @@ static struct sock *raw_sock_get(struct
  
        read_lock(&hashinfo->lock);
        for (slot = 0; slot < RAW_HTABLE_SIZE; slot++) {
@@ -264,7 +257,7 @@ index ccacbde30a2c50..b6d92dc7b051d1 100644
                                /*
                                 * Grab it and keep until we fill
                                 * diag meaage to be reported, so
-@@ -81,10 +79,11 @@ static struct sock *raw_sock_get(struct net *net, const struct inet_diag_req_v2
+@@ -81,10 +79,11 @@ static struct sock *raw_sock_get(struct
                        }
                }
        }
@@ -277,8 +270,6 @@ index ccacbde30a2c50..b6d92dc7b051d1 100644
  }
  
  static int raw_diag_dump_one(struct netlink_callback *cb,
-diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
-index 3308b9a4d52378..16ff46c4f300e1 100644
 --- a/net/ipv6/raw.c
 +++ b/net/ipv6/raw.c
 @@ -66,41 +66,27 @@ struct raw_hashinfo raw_v6_hashinfo = {
@@ -293,7 +284,20 @@ index 3308b9a4d52378..16ff46c4f300e1 100644
 +                const struct in6_addr *rmt_addr, int dif, int sdif)
  {
 -      bool is_multicast = ipv6_addr_is_multicast(loc_addr);
--
++      if (inet_sk(sk)->inet_num != num ||
++          !net_eq(sock_net(sk), net) ||
++          (!ipv6_addr_any(&sk->sk_v6_daddr) &&
++           !ipv6_addr_equal(&sk->sk_v6_daddr, rmt_addr)) ||
++          !raw_sk_bound_dev_eq(net, sk->sk_bound_dev_if,
++                               dif, sdif))
++              return false;
++
++      if (ipv6_addr_any(&sk->sk_v6_rcv_saddr) ||
++          ipv6_addr_equal(&sk->sk_v6_rcv_saddr, loc_addr) ||
++          (ipv6_addr_is_multicast(loc_addr) &&
++           inet6_mc_check(sk, loc_addr, rmt_addr)))
++              return true;
 -      sk_for_each_from(sk)
 -              if (inet_sk(sk)->inet_num == num) {
 -
@@ -321,20 +325,6 @@ index 3308b9a4d52378..16ff46c4f300e1 100644
 -      sk = NULL;
 -found:
 -      return sk;
-+      if (inet_sk(sk)->inet_num != num ||
-+          !net_eq(sock_net(sk), net) ||
-+          (!ipv6_addr_any(&sk->sk_v6_daddr) &&
-+           !ipv6_addr_equal(&sk->sk_v6_daddr, rmt_addr)) ||
-+          !raw_sk_bound_dev_eq(net, sk->sk_bound_dev_if,
-+                               dif, sdif))
-+              return false;
-+
-+      if (ipv6_addr_any(&sk->sk_v6_rcv_saddr) ||
-+          ipv6_addr_equal(&sk->sk_v6_rcv_saddr, loc_addr) ||
-+          (ipv6_addr_is_multicast(loc_addr) &&
-+           inet6_mc_check(sk, loc_addr, rmt_addr)))
-+              return true;
-+
 +      return false;
  }
 -EXPORT_SYMBOL_GPL(__raw_v6_lookup);
@@ -342,7 +332,7 @@ index 3308b9a4d52378..16ff46c4f300e1 100644
  
  /*
   *    0 - deliver
-@@ -156,31 +142,28 @@ EXPORT_SYMBOL(rawv6_mh_filter_unregister);
+@@ -156,31 +142,28 @@ EXPORT_SYMBOL(rawv6_mh_filter_unregister
   */
  static bool ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)
  {
@@ -383,7 +373,7 @@ index 3308b9a4d52378..16ff46c4f300e1 100644
                delivered = true;
                switch (nexthdr) {
                case IPPROTO_ICMPV6:
-@@ -219,23 +202,14 @@ static bool ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)
+@@ -219,23 +202,14 @@ static bool ipv6_raw_deliver(struct sk_b
                                rawv6_rcv(sk, clone);
                        }
                }
@@ -408,7 +398,7 @@ index 3308b9a4d52378..16ff46c4f300e1 100644
  }
  
  /* This cleans up af_inet6 a bit. -DaveM */
-@@ -361,28 +335,25 @@ static void rawv6_err(struct sock *sk, struct sk_buff *skb,
+@@ -361,28 +335,25 @@ static void rawv6_err(struct sock *sk, s
  void raw6_icmp_error(struct sk_buff *skb, int nexthdr,
                u8 type, u8 code, int inner_offset, __be32 info)
  {
@@ -446,6 +436,3 @@ index 3308b9a4d52378..16ff46c4f300e1 100644
        }
        read_unlock(&raw_v6_hashinfo.lock);
  }
--- 
-2.53.0
-
index 0268aa908b3bd1ed31c82322404c40a592cb9e7d..3f315c7bd9462a1de2203322c512251f7ab850ab 100644 (file)
@@ -16,15 +16,13 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
 Stable-dep-of: 440e274da4d1 ("net: ipv6: fix dif and sdif mismatch in raw6_icmp_error")
 Signed-off-by: Sasha Levin <sashal@kernel.org>
 ---
- include/net/raw.h   |   5 +--
- include/net/rawv6.h |   6 +--
- net/ipv4/raw.c      |  93 ++++++++++++++-------------------------
- net/ipv4/raw_diag.c |  33 +++++++-------
- net/ipv6/raw.c      | 105 ++++++++++++++++----------------------------
+ include/net/raw.h   |    5 +-
+ include/net/rawv6.h |    6 +--
+ net/ipv4/raw.c      |   95 +++++++++++++++++------------------------------
+ net/ipv4/raw_diag.c |   33 ++++++++--------
+ net/ipv6/raw.c      |  103 ++++++++++++++++++----------------------------------
  5 files changed, 92 insertions(+), 150 deletions(-)
 
-diff --git a/include/net/raw.h b/include/net/raw.h
-index c51a635671a73d..6324965779ec6a 100644
 --- a/include/net/raw.h
 +++ b/include/net/raw.h
 @@ -20,9 +20,8 @@
@@ -39,8 +37,6 @@ index c51a635671a73d..6324965779ec6a 100644
  
  int raw_abort(struct sock *sk, int err);
  void raw_icmp_error(struct sk_buff *, int, u32);
-diff --git a/include/net/rawv6.h b/include/net/rawv6.h
-index 53d86b6055e8cc..c48c1298699a04 100644
 --- a/include/net/rawv6.h
 +++ b/include/net/rawv6.h
 @@ -5,9 +5,9 @@
@@ -56,8 +52,6 @@ index 53d86b6055e8cc..c48c1298699a04 100644
  
  int raw_abort(struct sock *sk, int err);
  
-diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
-index e6cb76ecbf2d9f..2271f679265c4d 100644
 --- a/net/ipv4/raw.c
 +++ b/net/ipv4/raw.c
 @@ -117,24 +117,19 @@ void raw_unhash_sk(struct sock *sk)
@@ -67,9 +61,7 @@ index e6cb76ecbf2d9f..2271f679265c4d 100644
 -struct sock *__raw_v4_lookup(struct net *net, struct sock *sk,
 -                           unsigned short num, __be32 raddr, __be32 laddr,
 -                           int dif, int sdif)
-+bool raw_v4_match(struct net *net, struct sock *sk, unsigned short num,
-+                __be32 raddr, __be32 laddr, int dif, int sdif)
- {
+-{
 -      sk_for_each_from(sk) {
 -              struct inet_sock *inet = inet_sk(sk);
 -
@@ -82,6 +74,9 @@ index e6cb76ecbf2d9f..2271f679265c4d 100644
 -      sk = NULL;
 -found:
 -      return sk;
++bool raw_v4_match(struct net *net, struct sock *sk, unsigned short num,
++                __be32 raddr, __be32 laddr, int dif, int sdif)
++{
 +      struct inet_sock *inet = inet_sk(sk);
 +
 +      if (net_eq(sock_net(sk), net) && inet->inet_num == num  &&
@@ -96,7 +91,7 @@ index e6cb76ecbf2d9f..2271f679265c4d 100644
  
  /*
   *    0 - deliver
-@@ -168,23 +163,21 @@ static int icmp_filter(const struct sock *sk, const struct sk_buff *skb)
+@@ -168,23 +163,21 @@ static int icmp_filter(const struct sock
   */
  static int raw_v4_input(struct sk_buff *skb, const struct iphdr *iph, int hash)
  {
@@ -128,7 +123,7 @@ index e6cb76ecbf2d9f..2271f679265c4d 100644
                delivered = 1;
                if ((iph->protocol != IPPROTO_ICMP || !icmp_filter(sk, skb)) &&
                    ip_mc_sf_allow(sk, iph->daddr, iph->saddr,
-@@ -195,31 +188,16 @@ static int raw_v4_input(struct sk_buff *skb, const struct iphdr *iph, int hash)
+@@ -195,31 +188,16 @@ static int raw_v4_input(struct sk_buff *
                        if (clone)
                                raw_rcv(sk, clone);
                }
@@ -162,13 +157,13 @@ index e6cb76ecbf2d9f..2271f679265c4d 100644
  }
  
  static void raw_err(struct sock *sk, struct sk_buff *skb, u32 info)
-@@ -286,29 +264,24 @@ static void raw_err(struct sock *sk, struct sk_buff *skb, u32 info)
+@@ -286,29 +264,24 @@ static void raw_err(struct sock *sk, str
  
  void raw_icmp_error(struct sk_buff *skb, int protocol, u32 info)
  {
 -      int hash;
 -      struct sock *raw_sk;
-+      struct net *net = dev_net(skb->dev);;
++      struct net *net = dev_net(skb->dev);
 +      int dif = skb->dev->ifindex;
 +      int sdif = inet_sdif(skb);
 +      struct hlist_head *head;
@@ -204,11 +199,9 @@ index e6cb76ecbf2d9f..2271f679265c4d 100644
        }
        read_unlock(&raw_v4_hashinfo.lock);
  }
-diff --git a/net/ipv4/raw_diag.c b/net/ipv4/raw_diag.c
-index ccacbde30a2c50..b6d92dc7b051d1 100644
 --- a/net/ipv4/raw_diag.c
 +++ b/net/ipv4/raw_diag.c
-@@ -34,31 +34,30 @@ raw_get_hashinfo(const struct inet_diag_req_v2 *r)
+@@ -34,31 +34,30 @@ raw_get_hashinfo(const struct inet_diag_
   * use helper to figure it out.
   */
  
@@ -252,7 +245,7 @@ index ccacbde30a2c50..b6d92dc7b051d1 100644
        int slot;
  
        if (IS_ERR(hashinfo))
-@@ -66,9 +65,8 @@ static struct sock *raw_sock_get(struct net *net, const struct inet_diag_req_v2
+@@ -66,9 +65,8 @@ static struct sock *raw_sock_get(struct
  
        read_lock(&hashinfo->lock);
        for (slot = 0; slot < RAW_HTABLE_SIZE; slot++) {
@@ -264,7 +257,7 @@ index ccacbde30a2c50..b6d92dc7b051d1 100644
                                /*
                                 * Grab it and keep until we fill
                                 * diag meaage to be reported, so
-@@ -81,10 +79,11 @@ static struct sock *raw_sock_get(struct net *net, const struct inet_diag_req_v2
+@@ -81,10 +79,11 @@ static struct sock *raw_sock_get(struct
                        }
                }
        }
@@ -277,8 +270,6 @@ index ccacbde30a2c50..b6d92dc7b051d1 100644
  }
  
  static int raw_diag_dump_one(struct netlink_callback *cb,
-diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
-index 586e972cbcd53c..7e816853cd1cd4 100644
 --- a/net/ipv6/raw.c
 +++ b/net/ipv6/raw.c
 @@ -66,41 +66,27 @@ struct raw_hashinfo raw_v6_hashinfo = {
@@ -293,7 +284,20 @@ index 586e972cbcd53c..7e816853cd1cd4 100644
 +                const struct in6_addr *rmt_addr, int dif, int sdif)
  {
 -      bool is_multicast = ipv6_addr_is_multicast(loc_addr);
--
++      if (inet_sk(sk)->inet_num != num ||
++          !net_eq(sock_net(sk), net) ||
++          (!ipv6_addr_any(&sk->sk_v6_daddr) &&
++           !ipv6_addr_equal(&sk->sk_v6_daddr, rmt_addr)) ||
++          !raw_sk_bound_dev_eq(net, sk->sk_bound_dev_if,
++                               dif, sdif))
++              return false;
++
++      if (ipv6_addr_any(&sk->sk_v6_rcv_saddr) ||
++          ipv6_addr_equal(&sk->sk_v6_rcv_saddr, loc_addr) ||
++          (ipv6_addr_is_multicast(loc_addr) &&
++           inet6_mc_check(sk, loc_addr, rmt_addr)))
++              return true;
 -      sk_for_each_from(sk)
 -              if (inet_sk(sk)->inet_num == num) {
 -
@@ -321,20 +325,6 @@ index 586e972cbcd53c..7e816853cd1cd4 100644
 -      sk = NULL;
 -found:
 -      return sk;
-+      if (inet_sk(sk)->inet_num != num ||
-+          !net_eq(sock_net(sk), net) ||
-+          (!ipv6_addr_any(&sk->sk_v6_daddr) &&
-+           !ipv6_addr_equal(&sk->sk_v6_daddr, rmt_addr)) ||
-+          !raw_sk_bound_dev_eq(net, sk->sk_bound_dev_if,
-+                               dif, sdif))
-+              return false;
-+
-+      if (ipv6_addr_any(&sk->sk_v6_rcv_saddr) ||
-+          ipv6_addr_equal(&sk->sk_v6_rcv_saddr, loc_addr) ||
-+          (ipv6_addr_is_multicast(loc_addr) &&
-+           inet6_mc_check(sk, loc_addr, rmt_addr)))
-+              return true;
-+
 +      return false;
  }
 -EXPORT_SYMBOL_GPL(__raw_v6_lookup);
@@ -342,7 +332,7 @@ index 586e972cbcd53c..7e816853cd1cd4 100644
  
  /*
   *    0 - deliver
-@@ -156,31 +142,28 @@ EXPORT_SYMBOL(rawv6_mh_filter_unregister);
+@@ -156,31 +142,28 @@ EXPORT_SYMBOL(rawv6_mh_filter_unregister
   */
  static bool ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)
  {
@@ -383,7 +373,7 @@ index 586e972cbcd53c..7e816853cd1cd4 100644
                delivered = true;
                switch (nexthdr) {
                case IPPROTO_ICMPV6:
-@@ -219,23 +202,14 @@ static bool ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)
+@@ -219,23 +202,14 @@ static bool ipv6_raw_deliver(struct sk_b
                                rawv6_rcv(sk, clone);
                        }
                }
@@ -408,7 +398,7 @@ index 586e972cbcd53c..7e816853cd1cd4 100644
  }
  
  /* This cleans up af_inet6 a bit. -DaveM */
-@@ -361,28 +335,25 @@ static void rawv6_err(struct sock *sk, struct sk_buff *skb,
+@@ -361,28 +335,25 @@ static void rawv6_err(struct sock *sk, s
  void raw6_icmp_error(struct sk_buff *skb, int nexthdr,
                u8 type, u8 code, int inner_offset, __be32 info)
  {
@@ -446,6 +436,3 @@ index 586e972cbcd53c..7e816853cd1cd4 100644
        }
        read_unlock(&raw_v6_hashinfo.lock);
  }
--- 
-2.53.0
-