netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: ooppublic@163.com
To: davem@davemloft.net
Cc: dsahern@kernel.org, netdev@vger.kernel.org, caixf <ooppublic@163.com>
Subject: [PATCH] net: fix fragments have the disallowed options
Date: Fri,  7 Jan 2022 16:05:59 +0800	[thread overview]
Message-ID: <20220107080559.122713-1-ooppublic@163.com> (raw)

From: caixf <ooppublic@163.com>

When in function ip_do_fragment() enter fsat path,
if skb have opthons, all fragments will have the same options.

Just guarantee the second fragment not have the disallowed options.

Signed-off-by: caixf <ooppublic@163.com>
---
 net/ipv4/ip_output.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 9bca57ef8b83..ce178b5eb848 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -826,15 +826,16 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
 		/* Everything is OK. Generate! */
 		ip_fraglist_init(skb, iph, hlen, &iter);
 
-		if (iter.frag)
-			ip_options_fragment(iter.frag);
-
 		for (;;) {
 			/* Prepare header of the next frame,
 			 * before previous one went down. */
 			if (iter.frag) {
+				bool first_frag = (iter.offset == 0);
+
 				IPCB(iter.frag)->flags = IPCB(skb)->flags;
 				ip_fraglist_prepare(skb, &iter);
+				if (first_frag)
+					ip_options_fragment(iter.frag);
 			}
 
 			skb->tstamp = tstamp;
-- 
2.34.1



             reply	other threads:[~2022-01-07  8:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-07  8:05 ooppublic [this message]
2022-01-12 18:43 ` [PATCH] net: fix fragments have the disallowed options Jakub Kicinski
2022-01-18 21:10   ` Jakub Kicinski
2022-01-12 18:46 ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220107080559.122713-1-ooppublic@163.com \
    --to=ooppublic@163.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).