sctp: Drop ipfargok in sctp_xmit function

The ipfragok flag controls whether the packet may be fragmented
either on the local host on beyond. The latter is only valid on
IPv4.

In fact, we never want to do the latter even on IPv4 when PMTU is
enabled. This is because even though we can't fragment packets
within SCTP due to the prtocol's inherent faults, we can still
fragment it at IP layer. By setting the DF bit we will improve
the PMTU process.

RFC 2960 only says that we SHOULD clear the DF bit in this case,
so we're compliant even if we set the DF bit. In fact RFC 4960
no longer has this statement.

Once we make this change, we only need to control the local
fragmentation. There is already a bit in the skb which controls
that, local_df. So this patch sets that instead of using the
ipfragok argument.

The only complication is that there isn't a struct sock object
per transport, so for IPv4 we have to resort to changing the
pmtudisc field for every packet. This should be safe though
as the protocol is single-threaded.

Note that after this patch we can remove ipfragok from the rest
of the stack too.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Herbert Xu and committed by David S. Miller f880374c cfb266c0

+15 -11
+1 -2
include/net/sctp/structs.h
··· 524 */ 525 struct sctp_af { 526 int (*sctp_xmit) (struct sk_buff *skb, 527 - struct sctp_transport *, 528 - int ipfragok); 529 int (*setsockopt) (struct sock *sk, 530 int level, 531 int optname,
··· 524 */ 525 struct sctp_af { 526 int (*sctp_xmit) (struct sk_buff *skb, 527 + struct sctp_transport *); 528 int (*setsockopt) (struct sock *sk, 529 int level, 530 int optname,
+5 -3
net/sctp/ipv6.c
··· 195 } 196 197 /* Based on tcp_v6_xmit() in tcp_ipv6.c. */ 198 - static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport, 199 - int ipfragok) 200 { 201 struct sock *sk = skb->sk; 202 struct ipv6_pinfo *np = inet6_sk(sk); ··· 230 231 SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS); 232 233 - return ip6_xmit(sk, skb, &fl, np->opt, ipfragok); 234 } 235 236 /* Returns the dst cache entry for the given source and destination ip
··· 195 } 196 197 /* Based on tcp_v6_xmit() in tcp_ipv6.c. */ 198 + static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport) 199 { 200 struct sock *sk = skb->sk; 201 struct ipv6_pinfo *np = inet6_sk(sk); ··· 231 232 SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS); 233 234 + if (!(transport->param_flags & SPP_PMTUD_ENABLE)) 235 + skb->local_df = 1; 236 + 237 + return ip6_xmit(sk, skb, &fl, np->opt, 0); 238 } 239 240 /* Returns the dst cache entry for the given source and destination ip
+2 -4
net/sctp/output.c
··· 586 SCTP_DEBUG_PRINTK("***sctp_transmit_packet*** skb len %d\n", 587 nskb->len); 588 589 - if (tp->param_flags & SPP_PMTUD_ENABLE) 590 - (*tp->af_specific->sctp_xmit)(nskb, tp, packet->ipfragok); 591 - else 592 - (*tp->af_specific->sctp_xmit)(nskb, tp, 1); 593 594 out: 595 packet->size = packet->overhead;
··· 586 SCTP_DEBUG_PRINTK("***sctp_transmit_packet*** skb len %d\n", 587 nskb->len); 588 589 + nskb->local_df = packet->ipfragok; 590 + (*tp->af_specific->sctp_xmit)(nskb, tp); 591 592 out: 593 packet->size = packet->overhead;
+7 -2
net/sctp/protocol.c
··· 862 863 /* Wrapper routine that calls the ip transmit routine. */ 864 static inline int sctp_v4_xmit(struct sk_buff *skb, 865 - struct sctp_transport *transport, int ipfragok) 866 { 867 SCTP_DEBUG_PRINTK("%s: skb:%p, len:%d, " 868 "src:%u.%u.%u.%u, dst:%u.%u.%u.%u\n", 869 __func__, skb, skb->len, 870 NIPQUAD(skb->rtable->rt_src), 871 NIPQUAD(skb->rtable->rt_dst)); 872 873 SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS); 874 - return ip_queue_xmit(skb, ipfragok); 875 } 876 877 static struct sctp_af sctp_af_inet;
··· 862 863 /* Wrapper routine that calls the ip transmit routine. */ 864 static inline int sctp_v4_xmit(struct sk_buff *skb, 865 + struct sctp_transport *transport) 866 { 867 + struct inet_sock *inet = inet_sk(skb->sk); 868 + 869 SCTP_DEBUG_PRINTK("%s: skb:%p, len:%d, " 870 "src:%u.%u.%u.%u, dst:%u.%u.%u.%u\n", 871 __func__, skb, skb->len, 872 NIPQUAD(skb->rtable->rt_src), 873 NIPQUAD(skb->rtable->rt_dst)); 874 875 + inet->pmtudisc = transport->param_flags & SPP_PMTUD_ENABLE ? 876 + IP_PMTUDISC_DO : IP_PMTUDISC_DONT; 877 + 878 SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS); 879 + return ip_queue_xmit(skb, 0); 880 } 881 882 static struct sctp_af sctp_af_inet;