tipc: add tipc_bearer_min_mtu to calculate min mtu
[ Upstream commit 3ae6d66b605be604644d4bb5708a7ffd9cf1abe8 ] 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.xin@gmail.com> Acked-by: Jon Maloy <jmaloy@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net> Stable-dep-of: 56077b56cd3f ("tipc: do not update mtu if msg_max is too small in mtu negotiation") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
76ea144a35
commit
097ea78d8c
@@ -525,6 +525,19 @@ int tipc_bearer_mtu(struct net *net, u32 bearer_id)
|
|||||||
return mtu;
|
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 = bearer_get(net, bearer_id);
|
||||||
|
if (b)
|
||||||
|
mtu += b->encap_hlen;
|
||||||
|
rcu_read_unlock();
|
||||||
|
return mtu;
|
||||||
|
}
|
||||||
|
|
||||||
/* tipc_bearer_xmit_skb - sends buffer to destination over bearer
|
/* tipc_bearer_xmit_skb - sends buffer to destination over bearer
|
||||||
*/
|
*/
|
||||||
void tipc_bearer_xmit_skb(struct net *net, u32 bearer_id,
|
void tipc_bearer_xmit_skb(struct net *net, u32 bearer_id,
|
||||||
|
@@ -146,6 +146,7 @@ struct tipc_media {
|
|||||||
* @identity: array index of this bearer within TIPC bearer array
|
* @identity: array index of this bearer within TIPC bearer array
|
||||||
* @disc: ptr to link setup request
|
* @disc: ptr to link setup request
|
||||||
* @net_plane: network plane ('A' through 'H') currently associated with bearer
|
* @net_plane: network plane ('A' through 'H') currently associated with bearer
|
||||||
|
* @encap_hlen: encap headers length
|
||||||
* @up: bearer up flag (bit 0)
|
* @up: bearer up flag (bit 0)
|
||||||
* @refcnt: tipc_bearer reference counter
|
* @refcnt: tipc_bearer reference counter
|
||||||
*
|
*
|
||||||
@@ -170,6 +171,7 @@ struct tipc_bearer {
|
|||||||
u32 identity;
|
u32 identity;
|
||||||
struct tipc_discoverer *disc;
|
struct tipc_discoverer *disc;
|
||||||
char net_plane;
|
char net_plane;
|
||||||
|
u16 encap_hlen;
|
||||||
unsigned long up;
|
unsigned long up;
|
||||||
refcount_t refcnt;
|
refcount_t refcnt;
|
||||||
};
|
};
|
||||||
@@ -232,6 +234,7 @@ int tipc_bearer_setup(void);
|
|||||||
void tipc_bearer_cleanup(void);
|
void tipc_bearer_cleanup(void);
|
||||||
void tipc_bearer_stop(struct net *net);
|
void tipc_bearer_stop(struct net *net);
|
||||||
int tipc_bearer_mtu(struct net *net, u32 bearer_id);
|
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);
|
bool tipc_bearer_bcast_support(struct net *net, u32 bearer_id);
|
||||||
void tipc_bearer_xmit_skb(struct net *net, u32 bearer_id,
|
void tipc_bearer_xmit_skb(struct net *net, u32 bearer_id,
|
||||||
struct sk_buff *skb,
|
struct sk_buff *skb,
|
||||||
|
@@ -730,8 +730,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.local_ip.s_addr = local.ipv4.s_addr;
|
||||||
udp_conf.use_udp_checksums = false;
|
udp_conf.use_udp_checksums = false;
|
||||||
ub->ifindex = dev->ifindex;
|
ub->ifindex = dev->ifindex;
|
||||||
if (tipc_mtu_bad(dev, sizeof(struct iphdr) +
|
b->encap_hlen = sizeof(struct iphdr) + sizeof(struct udphdr);
|
||||||
sizeof(struct udphdr))) {
|
if (tipc_mtu_bad(dev, b->encap_hlen)) {
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@@ -752,6 +752,7 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
|
|||||||
else
|
else
|
||||||
udp_conf.local_ip6 = local.ipv6;
|
udp_conf.local_ip6 = local.ipv6;
|
||||||
ub->ifindex = dev->ifindex;
|
ub->ifindex = dev->ifindex;
|
||||||
|
b->encap_hlen = sizeof(struct ipv6hdr) + sizeof(struct udphdr);
|
||||||
b->mtu = 1280;
|
b->mtu = 1280;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user