Skip to content

Commit 2f56c48

Browse files
Yajun Denggregkh
authored andcommitted
net: ipv4: Move ip_options_fragment() out of loop
[ Upstream commit faf482c ] The ip_options_fragment() only called when iter->offset is equal to zero, so move it out of loop, and inline 'Copy the flags to each fragment.' As also, remove the unused parameter in ip_frag_ipcb(). Signed-off-by: Yajun Deng <yajun.deng@linux.dev> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 55402a4 commit 2f56c48

1 file changed

Lines changed: 4 additions & 15 deletions

File tree

‎net/ipv4/ip_output.c‎

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -614,18 +614,6 @@ void ip_fraglist_init(struct sk_buff *skb, struct iphdr *iph,
614614
}
615615
EXPORT_SYMBOL(ip_fraglist_init);
616616

617-
static void ip_fraglist_ipcb_prepare(struct sk_buff *skb,
618-
struct ip_fraglist_iter *iter)
619-
{
620-
struct sk_buff *to = iter->frag;
621-
622-
/* Copy the flags to each fragment. */
623-
IPCB(to)->flags = IPCB(skb)->flags;
624-
625-
if (iter->offset == 0)
626-
ip_options_fragment(to);
627-
}
628-
629617
void ip_fraglist_prepare(struct sk_buff *skb, struct ip_fraglist_iter *iter)
630618
{
631619
unsigned int hlen = iter->hlen;
@@ -671,7 +659,7 @@ void ip_frag_init(struct sk_buff *skb, unsigned int hlen,
671659
EXPORT_SYMBOL(ip_frag_init);
672660

673661
static void ip_frag_ipcb(struct sk_buff *from, struct sk_buff *to,
674-
bool first_frag, struct ip_frag_state *state)
662+
bool first_frag)
675663
{
676664
/* Copy the flags to each fragment. */
677665
IPCB(to)->flags = IPCB(from)->flags;
@@ -845,12 +833,13 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
845833

846834
/* Everything is OK. Generate! */
847835
ip_fraglist_init(skb, iph, hlen, &iter);
836+
ip_options_fragment(iter.frag);
848837

849838
for (;;) {
850839
/* Prepare header of the next frame,
851840
* before previous one went down. */
852841
if (iter.frag) {
853-
ip_fraglist_ipcb_prepare(skb, &iter);
842+
IPCB(iter.frag)->flags = IPCB(skb)->flags;
854843
ip_fraglist_prepare(skb, &iter);
855844
}
856845

@@ -905,7 +894,7 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
905894
err = PTR_ERR(skb2);
906895
goto fail;
907896
}
908-
ip_frag_ipcb(skb, skb2, first_frag, &state);
897+
ip_frag_ipcb(skb, skb2, first_frag);
909898

910899
/*
911900
* Put this fragment into the sending queue.

0 commit comments

Comments
 (0)