Skip to content

Commit

Permalink
net: ipv4: Move ip_options_fragment() out of loop
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Yajun Deng authored and David S. Miller committed Aug 24, 2021
1 parent 1bb39cb commit faf482c
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions net/ipv4/ip_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,18 +606,6 @@ void ip_fraglist_init(struct sk_buff *skb, struct iphdr *iph,
}
EXPORT_SYMBOL(ip_fraglist_init);

static void ip_fraglist_ipcb_prepare(struct sk_buff *skb,
struct ip_fraglist_iter *iter)
{
struct sk_buff *to = iter->frag;

/* Copy the flags to each fragment. */
IPCB(to)->flags = IPCB(skb)->flags;

if (iter->offset == 0)
ip_options_fragment(to);
}

void ip_fraglist_prepare(struct sk_buff *skb, struct ip_fraglist_iter *iter)
{
unsigned int hlen = iter->hlen;
Expand Down Expand Up @@ -663,7 +651,7 @@ void ip_frag_init(struct sk_buff *skb, unsigned int hlen,
EXPORT_SYMBOL(ip_frag_init);

static void ip_frag_ipcb(struct sk_buff *from, struct sk_buff *to,
bool first_frag, struct ip_frag_state *state)
bool first_frag)
{
/* Copy the flags to each fragment. */
IPCB(to)->flags = IPCB(from)->flags;
Expand Down Expand Up @@ -837,12 +825,13 @@ 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);
ip_options_fragment(iter.frag);

for (;;) {
/* Prepare header of the next frame,
* before previous one went down. */
if (iter.frag) {
ip_fraglist_ipcb_prepare(skb, &iter);
IPCB(iter.frag)->flags = IPCB(skb)->flags;
ip_fraglist_prepare(skb, &iter);
}

Expand Down Expand Up @@ -897,7 +886,7 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
err = PTR_ERR(skb2);
goto fail;
}
ip_frag_ipcb(skb, skb2, first_frag, &state);
ip_frag_ipcb(skb, skb2, first_frag);

/*
* Put this fragment into the sending queue.
Expand Down

0 comments on commit faf482c

Please sign in to comment.