ip: constify ip_build_and_send_pkt() socket argument
This function is used to build and send SYNACK packets, possibly on behalf of unlocked listener socket. Make sure we did not miss a write by making this socket const. We no longer can use ip_select_ident() and have to either set iph->id to 0 or directly call __ip_select_ident() Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
b83e3deb97
commit
cfe673b0ae
|
@ -100,7 +100,7 @@ int igmp_mc_init(void);
|
||||||
* Functions provided by ip.c
|
* Functions provided by ip.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
|
int ip_build_and_send_pkt(struct sk_buff *skb, const struct sock *sk,
|
||||||
__be32 saddr, __be32 daddr,
|
__be32 saddr, __be32 daddr,
|
||||||
struct ip_options_rcu *opt);
|
struct ip_options_rcu *opt);
|
||||||
int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
|
int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
|
||||||
|
|
|
@ -137,7 +137,7 @@ static inline int ip_select_ttl(struct inet_sock *inet, struct dst_entry *dst)
|
||||||
* Add an ip header to a skbuff and send it out.
|
* Add an ip header to a skbuff and send it out.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
|
int ip_build_and_send_pkt(struct sk_buff *skb, const struct sock *sk,
|
||||||
__be32 saddr, __be32 daddr, struct ip_options_rcu *opt)
|
__be32 saddr, __be32 daddr, struct ip_options_rcu *opt)
|
||||||
{
|
{
|
||||||
struct inet_sock *inet = inet_sk(sk);
|
struct inet_sock *inet = inet_sk(sk);
|
||||||
|
@ -151,15 +151,17 @@ int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
|
||||||
iph->version = 4;
|
iph->version = 4;
|
||||||
iph->ihl = 5;
|
iph->ihl = 5;
|
||||||
iph->tos = inet->tos;
|
iph->tos = inet->tos;
|
||||||
if (ip_dont_fragment(sk, &rt->dst))
|
|
||||||
iph->frag_off = htons(IP_DF);
|
|
||||||
else
|
|
||||||
iph->frag_off = 0;
|
|
||||||
iph->ttl = ip_select_ttl(inet, &rt->dst);
|
iph->ttl = ip_select_ttl(inet, &rt->dst);
|
||||||
iph->daddr = (opt && opt->opt.srr ? opt->opt.faddr : daddr);
|
iph->daddr = (opt && opt->opt.srr ? opt->opt.faddr : daddr);
|
||||||
iph->saddr = saddr;
|
iph->saddr = saddr;
|
||||||
iph->protocol = sk->sk_protocol;
|
iph->protocol = sk->sk_protocol;
|
||||||
ip_select_ident(sock_net(sk), skb, sk);
|
if (ip_dont_fragment(sk, &rt->dst)) {
|
||||||
|
iph->frag_off = htons(IP_DF);
|
||||||
|
iph->id = 0;
|
||||||
|
} else {
|
||||||
|
iph->frag_off = 0;
|
||||||
|
__ip_select_ident(sock_net(sk), iph, 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (opt && opt->opt.optlen) {
|
if (opt && opt->opt.optlen) {
|
||||||
iph->ihl += opt->opt.optlen>>2;
|
iph->ihl += opt->opt.optlen>>2;
|
||||||
|
|
Loading…
Reference in New Issue