Skip to content

Commit ba9ee5e

Browse files
NicolasDichtelbwhacks
authored andcommitted
sctp: check cached dst before using it
[ Upstream commit e026886 ] dst_check() will take care of SA (and obsolete field), hence IPsec rekeying scenario is taken into account. Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Acked-by: Vlad Yaseivch <vyasevich@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
1 parent 0fc2cf7 commit ba9ee5e

3 files changed

Lines changed: 14 additions & 20 deletions

File tree

‎include/net/sctp/sctp.h‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,4 +703,17 @@ static inline void sctp_v4_map_v6(union sctp_addr *addr)
703703
addr->v6.sin6_addr.s6_addr32[2] = htonl(0x0000ffff);
704704
}
705705

706+
/* The cookie is always 0 since this is how it's used in the
707+
* pmtu code.
708+
*/
709+
static inline struct dst_entry *sctp_transport_dst_check(struct sctp_transport *t)
710+
{
711+
if (t->dst && !dst_check(t->dst, 0)) {
712+
dst_release(t->dst);
713+
t->dst = NULL;
714+
}
715+
716+
return t->dst;
717+
}
718+
706719
#endif /* __net_sctp_h__ */

‎net/sctp/output.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,7 @@ int sctp_packet_transmit(struct sctp_packet *packet)
377377
*/
378378
skb_set_owner_w(nskb, sk);
379379

380-
/* The 'obsolete' field of dst is set to 2 when a dst is freed. */
381-
if (!dst || (dst->obsolete > 1)) {
382-
dst_release(dst);
380+
if (!sctp_transport_dst_check(tp)) {
383381
sctp_transport_route(tp, NULL, sctp_sk(sk));
384382
if (asoc && (asoc->param_flags & SPP_PMTUD_ENABLE)) {
385383
sctp_assoc_sync_pmtu(asoc);

‎net/sctp/transport.c‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -226,23 +226,6 @@ void sctp_transport_pmtu(struct sctp_transport *transport, struct sock *sk)
226226
transport->pathmtu = SCTP_DEFAULT_MAXSEGMENT;
227227
}
228228

229-
/* this is a complete rip-off from __sk_dst_check
230-
* the cookie is always 0 since this is how it's used in the
231-
* pmtu code
232-
*/
233-
static struct dst_entry *sctp_transport_dst_check(struct sctp_transport *t)
234-
{
235-
struct dst_entry *dst = t->dst;
236-
237-
if (dst && dst->obsolete && dst->ops->check(dst, 0) == NULL) {
238-
dst_release(t->dst);
239-
t->dst = NULL;
240-
return NULL;
241-
}
242-
243-
return dst;
244-
}
245-
246229
void sctp_transport_update_pmtu(struct sctp_transport *t, u32 pmtu)
247230
{
248231
struct dst_entry *dst;

0 commit comments

Comments
 (0)