>-----Original Message----- >From: Xin Long <lucien....@gmail.com> >Sent: Sunday, April 30, 2023 5:41 AM >To: network dev <net...@vger.kernel.org>; tipc-discussion@lists.sourceforge.net >Cc: k...@kernel.org; Eric Dumazet <eduma...@google.com>; Paolo Abeni ><pab...@redhat.com>; da...@davemloft.net >Subject: [tipc-discussion] [PATCH net 1/2] tipc: add tipc_bearer_min_mtu to >calculate min mtu > >As different media may requires different min mtu, and even the >same media with different net family requires different min mtu, >add tipc_bearer_min_mtu() to calculate min mtu accordingly. > >This API will be used to check the new mtu when doing the link >mtu negotiation in the next patch. > >Signed-off-by: Xin Long <lucien....@gmail.com> >--- > net/tipc/bearer.c | 13 +++++++++++++ > net/tipc/bearer.h | 3 +++ > net/tipc/udp_media.c | 5 +++-- > 3 files changed, 19 insertions(+), 2 deletions(-) > >diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c >index 35cac7733fd3..c5d2e8c45f88 100644 >--- a/net/tipc/bearer.c >+++ b/net/tipc/bearer.c >@@ -541,6 +541,19 @@ int tipc_bearer_mtu(struct net *net, u32 bearer_id) > return mtu; > } > >+int tipc_bearer_min_mtu(struct net *net, u32 bearer_id) >+{ >+ int mtu = TIPC_MIN_BEARER_MTU; >+ struct tipc_bearer *b; >+ >+ rcu_read_lock(); >+ b = rcu_dereference(tipc_net(net)->bearer_list[bearer_id]); >+ if (b) >+ mtu += b->encap_hlen; >+ rcu_read_unlock(); >+ return mtu; >+} >+ > /* tipc_bearer_xmit_skb - sends buffer to destination over bearer > */ > void tipc_bearer_xmit_skb(struct net *net, u32 bearer_id, >diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h >index 490ad6e5f7a3..bd0cc5c287ef 100644 >--- a/net/tipc/bearer.h >+++ b/net/tipc/bearer.h >@@ -146,6 +146,7 @@ struct tipc_media { > * @identity: array index of this bearer within TIPC bearer array > * @disc: ptr to link setup request > * @net_plane: network plane ('A' through 'H') currently associated with > bearer >+ * @encap_hlen: encap headers length > * @up: bearer up flag (bit 0) > * @refcnt: tipc_bearer reference counter > * >@@ -170,6 +171,7 @@ struct tipc_bearer { > u32 identity; > struct tipc_discoverer *disc; > char net_plane; >+ u16 encap_hlen; > unsigned long up; > refcount_t refcnt; > }; >@@ -232,6 +234,7 @@ int tipc_bearer_setup(void); > void tipc_bearer_cleanup(void); > void tipc_bearer_stop(struct net *net); > int tipc_bearer_mtu(struct net *net, u32 bearer_id); >+int tipc_bearer_min_mtu(struct net *net, u32 bearer_id); > bool tipc_bearer_bcast_support(struct net *net, u32 bearer_id); > void tipc_bearer_xmit_skb(struct net *net, u32 bearer_id, > struct sk_buff *skb, >diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c >index c2bb818704c8..0a85244fd618 100644 >--- a/net/tipc/udp_media.c >+++ b/net/tipc/udp_media.c >@@ -738,8 +738,8 @@ static int tipc_udp_enable(struct net *net, struct >tipc_bearer *b, > udp_conf.local_ip.s_addr = local.ipv4.s_addr; > udp_conf.use_udp_checksums = false; > ub->ifindex = dev->ifindex; >- if (tipc_mtu_bad(dev, sizeof(struct iphdr) + >- sizeof(struct udphdr))) { >+ b->encap_hlen = sizeof(struct iphdr) + sizeof(struct udphdr); >+ if (tipc_mtu_bad(dev, b->encap_hlen)) { > err = -EINVAL; > goto err; > } >@@ -760,6 +760,7 @@ static int tipc_udp_enable(struct net *net, struct >tipc_bearer *b, > else > udp_conf.local_ip6 = local.ipv6; > ub->ifindex = dev->ifindex; >+ b->encap_hlen = sizeof(struct ipv6hdr) + sizeof(struct udphdr); tipc_mtu_bad() needs to be called here to check for the minimum required MTU like the way ipv4 UDP bearer does. > b->mtu = 1280; > #endif > } else { >-- >2.39.1 > > > >_______________________________________________ >tipc-discussion mailing list >tipc-discussion@lists.sourceforge.net >https://lists.sourceforge.net/lists/listinfo/tipc-discussion _______________________________________________ tipc-discussion mailing list tipc-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tipc-discussion
Re: [tipc-discussion] [PATCH net 1/2] tipc: add tipc_bearer_min_mtu to calculate min mtu
Tung Quang Nguyen via tipc-discussion Sun, 30 Apr 2023 22:22:16 -0700
- [tipc-discussion] [PATCH net 0/2] ti... Xin Long
- [tipc-discussion] [PATCH net 2/... Xin Long
- Re: [tipc-discussion] [PATC... Tung Quang Nguyen via tipc-discussion
- Re: [tipc-discussion] [... Xin Long
- [tipc-discussion] [PATCH net 1/... Xin Long
- Re: [tipc-discussion] [PATC... Tung Quang Nguyen via tipc-discussion
- Re: [tipc-discussion] [... Xin Long
- Re: [tipc-discussio... Xin Long