This patch is to adjust the code in tipc_link_build_proto_msg() to make it able to build probe packet with a specific size for sender, and probe reply packet with mtu set.
Note that to send the probe packet, the df flag has to be set. Signed-off-by: Xin Long <lucien....@gmail.com> --- net/tipc/link.c | 38 +++++++++++++++++++++++--------------- net/tipc/link.h | 9 +++++++++ net/tipc/msg.c | 1 + net/tipc/udp_media.c | 3 ++- 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/net/tipc/link.c b/net/tipc/link.c index 1aa775cef3bb..414f9cf543ff 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c @@ -273,8 +273,8 @@ static int link_is_up(struct tipc_link *l) static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb, struct sk_buff_head *xmitq); -static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe, - bool probe_reply, u16 rcvgap, +static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, + u8 ptype, u32 mtu, u16 rcvgap, int tolerance, int priority, struct sk_buff_head *xmitq); static void link_print(struct tipc_link *l, const char *str); @@ -900,7 +900,7 @@ int tipc_link_timeout(struct tipc_link *l, struct sk_buff_head *xmitq) } if (state || probe || setup) - tipc_link_build_proto_msg(l, mtyp, probe, 0, 0, 0, 0, xmitq); + tipc_link_build_proto_msg(l, mtyp, PROBE_MSTATE, 0, 0, 0, 0, xmitq); return rc; } @@ -1862,8 +1862,8 @@ int tipc_link_rcv(struct tipc_link *l, struct sk_buff *skb, return rc; } -static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe, - bool probe_reply, u16 rcvgap, +static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, + u8 ptype, u32 mtu, u16 rcvgap, int tolerance, int priority, struct sk_buff_head *xmitq) { @@ -1874,7 +1874,7 @@ static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe, struct sk_buff *skb; bool node_up = link_is_up(bcl); u16 glen = 0, bc_rcvgap = 0; - int dlen = 0; + int dlen = 0, msg_sz; void *data; /* Don't send protocol message during reset or link failover */ @@ -1884,11 +1884,13 @@ static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe, if (!tipc_link_is_up(l) && (mtyp == STATE_MSG)) return; - if ((probe || probe_reply) && !skb_queue_empty(dfq)) + if (ptype && !skb_queue_empty(dfq)) rcvgap = buf_seqno(skb_peek(dfq)) - l->rcv_nxt; - skb = tipc_msg_create(LINK_PROTOCOL, mtyp, INT_H_SIZE, - tipc_max_domain_size + MAX_GAP_ACK_BLKS_SZ, + msg_sz = tipc_max_domain_size + MAX_GAP_ACK_BLKS_SZ; + if (ptype == PROBE_PLPMTU) + msg_sz = l->pl.probe_size - INT_H_SIZE; + skb = tipc_msg_create(LINK_PROTOCOL, mtyp, INT_H_SIZE, msg_sz, l->addr, tipc_own_addr(l->net), 0, 0, 0); if (!skb) return; @@ -1915,13 +1917,19 @@ static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe, msg_set_seq_gap(hdr, rcvgap); bc_rcvgap = link_bc_rcv_gap(bcl); msg_set_bc_gap(hdr, bc_rcvgap); - msg_set_probe(hdr, probe); - msg_set_is_keepalive(hdr, probe || probe_reply); + msg_set_probe(hdr, ptype == PROBE_MSTATE || ptype == PROBE_PLPMTU); + msg_set_is_keepalive(hdr, !!ptype); + if (ptype == PROBE_REPLY) + msg_set_max_pkt(hdr, mtu); if (l->peer_caps & TIPC_GAP_ACK_BLOCK) glen = tipc_build_gap_ack_blks(l, hdr); tipc_mon_prep(l->net, data + glen, &dlen, mstate, l->bearer_id); - msg_set_size(hdr, INT_H_SIZE + glen + dlen); - skb_trim(skb, INT_H_SIZE + glen + dlen); + if (ptype != PROBE_PLPMTU) { + msg_set_size(hdr, INT_H_SIZE + glen + dlen); + skb_trim(skb, INT_H_SIZE + glen + dlen); + } else { + skb->ignore_df = 0; + } l->stats.sent_states++; l->rcv_unacked = 0; } else { @@ -1935,7 +1943,7 @@ static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe, msg_set_size(hdr, INT_H_SIZE + TIPC_MAX_IF_NAME); skb_trim(skb, INT_H_SIZE + TIPC_MAX_IF_NAME); } - if (probe) + if (ptype == PROBE_MSTATE || ptype == PROBE_PLPMTU) l->stats.sent_probes++; if (rcvgap) l->stats.sent_nacks++; @@ -2329,7 +2337,7 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb, skb_queue_empty(&l->deferdq)) rcvgap = peers_snd_nxt - l->rcv_nxt; if (rcvgap || reply) - tipc_link_build_proto_msg(l, STATE_MSG, 0, reply, + tipc_link_build_proto_msg(l, STATE_MSG, PROBE_REPLY, msg_size(hdr), rcvgap, 0, 0, xmitq); released = tipc_link_advance_transmq(l, l, ack, gap, ga, xmitq, diff --git a/net/tipc/link.h b/net/tipc/link.h index 30bee2562987..87b3ebe5b91d 100644 --- a/net/tipc/link.h +++ b/net/tipc/link.h @@ -66,6 +66,15 @@ enum { TIPC_LINK_SND_STATE = (1 << 2) }; +/* Probe Type + */ +enum { + PROBE_NONE, + PROBE_MSTATE, + PROBE_REPLY, + PROBE_PLPMTU, +}; + /* PLPMTUD state */ enum { diff --git a/net/tipc/msg.c b/net/tipc/msg.c index 5c9fd4791c4b..6d8bcc180f8b 100644 --- a/net/tipc/msg.c +++ b/net/tipc/msg.c @@ -75,6 +75,7 @@ struct sk_buff *tipc_buf_acquire(u32 size, gfp_t gfp) skb_put(skb, size); skb->next = NULL; } + skb->ignore_df = 1; return skb; } diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c index dc4bae965549..5078c5b19e81 100644 --- a/net/tipc/udp_media.c +++ b/net/tipc/udp_media.c @@ -174,6 +174,7 @@ static int tipc_udp_xmit(struct net *net, struct sk_buff *skb, local_bh_disable(); ndst = dst_cache_get(cache); if (dst->proto == htons(ETH_P_IP)) { + u8 df = skb->ignore_df ? 0 : htons(IP_DF); struct rtable *rt = (struct rtable *)ndst; if (!rt) { @@ -193,7 +194,7 @@ static int tipc_udp_xmit(struct net *net, struct sk_buff *skb, ttl = ip4_dst_hoplimit(&rt->dst); udp_tunnel_xmit_skb(rt, ub->ubsock->sk, skb, src->ipv4.s_addr, - dst->ipv4.s_addr, 0, ttl, 0, src->port, + dst->ipv4.s_addr, 0, ttl, df, src->port, dst->port, false, true); #if IS_ENABLED(CONFIG_IPV6) } else { -- 2.27.0 _______________________________________________ tipc-discussion mailing list tipc-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tipc-discussion