Skip to content

Commit 24a2d43

Browse files
edumazetdavem330
authored andcommitted
ipv4: rename ip_options_echo to __ip_options_echo()
ip_options_echo() assumes struct ip_options is provided in &IPCB(skb)->opt Lets break this assumption, but provide a helper to not change all call points. ip_send_unicast_reply() gets a new struct ip_options pointer. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ff04a77 commit 24a2d43

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

include/net/ip.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,10 @@ static inline __u8 ip_reply_arg_flowi_flags(const struct ip_reply_arg *arg)
180180
return (arg->flags & IP_REPLY_ARG_NOSRCCHECK) ? FLOWI_FLAG_ANYSRC : 0;
181181
}
182182

183-
void ip_send_unicast_reply(struct net *net, struct sk_buff *skb, __be32 daddr,
184-
__be32 saddr, const struct ip_reply_arg *arg,
183+
void ip_send_unicast_reply(struct net *net, struct sk_buff *skb,
184+
const struct ip_options *sopt,
185+
__be32 daddr, __be32 saddr,
186+
const struct ip_reply_arg *arg,
185187
unsigned int len);
186188

187189
#define IP_INC_STATS(net, field) SNMP_INC_STATS64((net)->mib.ip_statistics, field)
@@ -511,7 +513,14 @@ int ip_forward(struct sk_buff *skb);
511513

512514
void ip_options_build(struct sk_buff *skb, struct ip_options *opt,
513515
__be32 daddr, struct rtable *rt, int is_frag);
514-
int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb);
516+
517+
int __ip_options_echo(struct ip_options *dopt, struct sk_buff *skb,
518+
const struct ip_options *sopt);
519+
static inline int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb)
520+
{
521+
return __ip_options_echo(dopt, skb, &IPCB(skb)->opt);
522+
}
523+
515524
void ip_options_fragment(struct sk_buff *skb);
516525
int ip_options_compile(struct net *net, struct ip_options *opt,
517526
struct sk_buff *skb);

net/ipv4/ip_options.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,15 @@ void ip_options_build(struct sk_buff *skb, struct ip_options *opt,
8787
* NOTE: dopt cannot point to skb.
8888
*/
8989

90-
int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb)
90+
int __ip_options_echo(struct ip_options *dopt, struct sk_buff *skb,
91+
const struct ip_options *sopt)
9192
{
92-
const struct ip_options *sopt;
9393
unsigned char *sptr, *dptr;
9494
int soffset, doffset;
9595
int optlen;
9696

9797
memset(dopt, 0, sizeof(struct ip_options));
9898

99-
sopt = &(IPCB(skb)->opt);
100-
10199
if (sopt->optlen == 0)
102100
return 0;
103101

net/ipv4/ip_output.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,8 +1522,10 @@ static DEFINE_PER_CPU(struct inet_sock, unicast_sock) = {
15221522
.uc_ttl = -1,
15231523
};
15241524

1525-
void ip_send_unicast_reply(struct net *net, struct sk_buff *skb, __be32 daddr,
1526-
__be32 saddr, const struct ip_reply_arg *arg,
1525+
void ip_send_unicast_reply(struct net *net, struct sk_buff *skb,
1526+
const struct ip_options *sopt,
1527+
__be32 daddr, __be32 saddr,
1528+
const struct ip_reply_arg *arg,
15271529
unsigned int len)
15281530
{
15291531
struct ip_options_data replyopts;
@@ -1534,7 +1536,7 @@ void ip_send_unicast_reply(struct net *net, struct sk_buff *skb, __be32 daddr,
15341536
struct sock *sk;
15351537
struct inet_sock *inet;
15361538

1537-
if (ip_options_echo(&replyopts.opt.opt, skb))
1539+
if (__ip_options_echo(&replyopts.opt.opt, skb, sopt))
15381540
return;
15391541

15401542
ipc.addr = daddr;

net/ipv4/tcp_ipv4.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -681,8 +681,9 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb)
681681

682682
net = dev_net(skb_dst(skb)->dev);
683683
arg.tos = ip_hdr(skb)->tos;
684-
ip_send_unicast_reply(net, skb, ip_hdr(skb)->saddr,
685-
ip_hdr(skb)->daddr, &arg, arg.iov[0].iov_len);
684+
ip_send_unicast_reply(net, skb, &TCP_SKB_CB(skb)->header.h4.opt,
685+
ip_hdr(skb)->saddr, ip_hdr(skb)->daddr,
686+
&arg, arg.iov[0].iov_len);
686687

687688
TCP_INC_STATS_BH(net, TCP_MIB_OUTSEGS);
688689
TCP_INC_STATS_BH(net, TCP_MIB_OUTRSTS);
@@ -764,8 +765,9 @@ static void tcp_v4_send_ack(struct sk_buff *skb, u32 seq, u32 ack,
764765
if (oif)
765766
arg.bound_dev_if = oif;
766767
arg.tos = tos;
767-
ip_send_unicast_reply(net, skb, ip_hdr(skb)->saddr,
768-
ip_hdr(skb)->daddr, &arg, arg.iov[0].iov_len);
768+
ip_send_unicast_reply(net, skb, &TCP_SKB_CB(skb)->header.h4.opt,
769+
ip_hdr(skb)->saddr, ip_hdr(skb)->daddr,
770+
&arg, arg.iov[0].iov_len);
769771

770772
TCP_INC_STATS_BH(net, TCP_MIB_OUTSEGS);
771773
}

0 commit comments

Comments
 (0)