diff options
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/bearer.c | 11 | ||||
-rw-r--r-- | net/tipc/bearer.h | 13 | ||||
-rw-r--r-- | net/tipc/link.c | 35 | ||||
-rw-r--r-- | net/tipc/udp_media.c | 5 |
4 files changed, 46 insertions, 18 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 975dbeb60ab0..52d74760fb68 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
@@ -421,6 +421,10 @@ int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b, | |||
421 | dev = dev_get_by_name(net, driver_name); | 421 | dev = dev_get_by_name(net, driver_name); |
422 | if (!dev) | 422 | if (!dev) |
423 | return -ENODEV; | 423 | return -ENODEV; |
424 | if (tipc_mtu_bad(dev, 0)) { | ||
425 | dev_put(dev); | ||
426 | return -EINVAL; | ||
427 | } | ||
424 | 428 | ||
425 | /* Associate TIPC bearer with L2 bearer */ | 429 | /* Associate TIPC bearer with L2 bearer */ |
426 | rcu_assign_pointer(b->media_ptr, dev); | 430 | rcu_assign_pointer(b->media_ptr, dev); |
@@ -610,8 +614,6 @@ static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt, | |||
610 | if (!b) | 614 | if (!b) |
611 | return NOTIFY_DONE; | 615 | return NOTIFY_DONE; |
612 | 616 | ||
613 | b->mtu = dev->mtu; | ||
614 | |||
615 | switch (evt) { | 617 | switch (evt) { |
616 | case NETDEV_CHANGE: | 618 | case NETDEV_CHANGE: |
617 | if (netif_carrier_ok(dev)) | 619 | if (netif_carrier_ok(dev)) |
@@ -624,6 +626,11 @@ static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt, | |||
624 | tipc_reset_bearer(net, b); | 626 | tipc_reset_bearer(net, b); |
625 | break; | 627 | break; |
626 | case NETDEV_CHANGEMTU: | 628 | case NETDEV_CHANGEMTU: |
629 | if (tipc_mtu_bad(dev, 0)) { | ||
630 | bearer_disable(net, b); | ||
631 | break; | ||
632 | } | ||
633 | b->mtu = dev->mtu; | ||
627 | tipc_reset_bearer(net, b); | 634 | tipc_reset_bearer(net, b); |
628 | break; | 635 | break; |
629 | case NETDEV_CHANGEADDR: | 636 | case NETDEV_CHANGEADDR: |
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h index 78892e2f53e3..278ff7f616f9 100644 --- a/net/tipc/bearer.h +++ b/net/tipc/bearer.h | |||
@@ -39,6 +39,7 @@ | |||
39 | 39 | ||
40 | #include "netlink.h" | 40 | #include "netlink.h" |
41 | #include "core.h" | 41 | #include "core.h" |
42 | #include "msg.h" | ||
42 | #include <net/genetlink.h> | 43 | #include <net/genetlink.h> |
43 | 44 | ||
44 | #define MAX_MEDIA 3 | 45 | #define MAX_MEDIA 3 |
@@ -59,6 +60,9 @@ | |||
59 | #define TIPC_MEDIA_TYPE_IB 2 | 60 | #define TIPC_MEDIA_TYPE_IB 2 |
60 | #define TIPC_MEDIA_TYPE_UDP 3 | 61 | #define TIPC_MEDIA_TYPE_UDP 3 |
61 | 62 | ||
63 | /* minimum bearer MTU */ | ||
64 | #define TIPC_MIN_BEARER_MTU (MAX_H_SIZE + INT_H_SIZE) | ||
65 | |||
62 | /** | 66 | /** |
63 | * struct tipc_media_addr - destination address used by TIPC bearers | 67 | * struct tipc_media_addr - destination address used by TIPC bearers |
64 | * @value: address info (format defined by media) | 68 | * @value: address info (format defined by media) |
@@ -215,4 +219,13 @@ void tipc_bearer_xmit(struct net *net, u32 bearer_id, | |||
215 | void tipc_bearer_bc_xmit(struct net *net, u32 bearer_id, | 219 | void tipc_bearer_bc_xmit(struct net *net, u32 bearer_id, |
216 | struct sk_buff_head *xmitq); | 220 | struct sk_buff_head *xmitq); |
217 | 221 | ||
222 | /* check if device MTU is too low for tipc headers */ | ||
223 | static inline bool tipc_mtu_bad(struct net_device *dev, unsigned int reserve) | ||
224 | { | ||
225 | if (dev->mtu >= TIPC_MIN_BEARER_MTU + reserve) | ||
226 | return false; | ||
227 | netdev_warn(dev, "MTU too low for tipc bearer\n"); | ||
228 | return true; | ||
229 | } | ||
230 | |||
218 | #endif /* _TIPC_BEARER_H */ | 231 | #endif /* _TIPC_BEARER_H */ |
diff --git a/net/tipc/link.c b/net/tipc/link.c index ecc12411155e..bda89bf9f4ff 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
@@ -47,8 +47,8 @@ | |||
47 | #include <linux/pkt_sched.h> | 47 | #include <linux/pkt_sched.h> |
48 | 48 | ||
49 | struct tipc_stats { | 49 | struct tipc_stats { |
50 | u32 sent_info; /* used in counting # sent packets */ | 50 | u32 sent_pkts; |
51 | u32 recv_info; /* used in counting # recv'd packets */ | 51 | u32 recv_pkts; |
52 | u32 sent_states; | 52 | u32 sent_states; |
53 | u32 recv_states; | 53 | u32 recv_states; |
54 | u32 sent_probes; | 54 | u32 sent_probes; |
@@ -857,7 +857,6 @@ void tipc_link_reset(struct tipc_link *l) | |||
857 | l->acked = 0; | 857 | l->acked = 0; |
858 | l->silent_intv_cnt = 0; | 858 | l->silent_intv_cnt = 0; |
859 | l->rst_cnt = 0; | 859 | l->rst_cnt = 0; |
860 | l->stats.recv_info = 0; | ||
861 | l->stale_count = 0; | 860 | l->stale_count = 0; |
862 | l->bc_peer_is_up = false; | 861 | l->bc_peer_is_up = false; |
863 | memset(&l->mon_state, 0, sizeof(l->mon_state)); | 862 | memset(&l->mon_state, 0, sizeof(l->mon_state)); |
@@ -888,6 +887,7 @@ int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list, | |||
888 | struct sk_buff_head *transmq = &l->transmq; | 887 | struct sk_buff_head *transmq = &l->transmq; |
889 | struct sk_buff_head *backlogq = &l->backlogq; | 888 | struct sk_buff_head *backlogq = &l->backlogq; |
890 | struct sk_buff *skb, *_skb, *bskb; | 889 | struct sk_buff *skb, *_skb, *bskb; |
890 | int pkt_cnt = skb_queue_len(list); | ||
891 | 891 | ||
892 | /* Match msg importance against this and all higher backlog limits: */ | 892 | /* Match msg importance against this and all higher backlog limits: */ |
893 | if (!skb_queue_empty(backlogq)) { | 893 | if (!skb_queue_empty(backlogq)) { |
@@ -901,6 +901,11 @@ int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list, | |||
901 | return -EMSGSIZE; | 901 | return -EMSGSIZE; |
902 | } | 902 | } |
903 | 903 | ||
904 | if (pkt_cnt > 1) { | ||
905 | l->stats.sent_fragmented++; | ||
906 | l->stats.sent_fragments += pkt_cnt; | ||
907 | } | ||
908 | |||
904 | /* Prepare each packet for sending, and add to relevant queue: */ | 909 | /* Prepare each packet for sending, and add to relevant queue: */ |
905 | while (skb_queue_len(list)) { | 910 | while (skb_queue_len(list)) { |
906 | skb = skb_peek(list); | 911 | skb = skb_peek(list); |
@@ -920,6 +925,7 @@ int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list, | |||
920 | __skb_queue_tail(xmitq, _skb); | 925 | __skb_queue_tail(xmitq, _skb); |
921 | TIPC_SKB_CB(skb)->ackers = l->ackers; | 926 | TIPC_SKB_CB(skb)->ackers = l->ackers; |
922 | l->rcv_unacked = 0; | 927 | l->rcv_unacked = 0; |
928 | l->stats.sent_pkts++; | ||
923 | seqno++; | 929 | seqno++; |
924 | continue; | 930 | continue; |
925 | } | 931 | } |
@@ -968,6 +974,7 @@ void tipc_link_advance_backlog(struct tipc_link *l, struct sk_buff_head *xmitq) | |||
968 | msg_set_ack(hdr, ack); | 974 | msg_set_ack(hdr, ack); |
969 | msg_set_bcast_ack(hdr, bc_ack); | 975 | msg_set_bcast_ack(hdr, bc_ack); |
970 | l->rcv_unacked = 0; | 976 | l->rcv_unacked = 0; |
977 | l->stats.sent_pkts++; | ||
971 | seqno++; | 978 | seqno++; |
972 | } | 979 | } |
973 | l->snd_nxt = seqno; | 980 | l->snd_nxt = seqno; |
@@ -1260,7 +1267,7 @@ int tipc_link_rcv(struct tipc_link *l, struct sk_buff *skb, | |||
1260 | 1267 | ||
1261 | /* Deliver packet */ | 1268 | /* Deliver packet */ |
1262 | l->rcv_nxt++; | 1269 | l->rcv_nxt++; |
1263 | l->stats.recv_info++; | 1270 | l->stats.recv_pkts++; |
1264 | if (!tipc_data_input(l, skb, l->inputq)) | 1271 | if (!tipc_data_input(l, skb, l->inputq)) |
1265 | rc |= tipc_link_input(l, skb, l->inputq); | 1272 | rc |= tipc_link_input(l, skb, l->inputq); |
1266 | if (unlikely(++l->rcv_unacked >= TIPC_MIN_LINK_WIN)) | 1273 | if (unlikely(++l->rcv_unacked >= TIPC_MIN_LINK_WIN)) |
@@ -1800,10 +1807,6 @@ void tipc_link_set_queue_limits(struct tipc_link *l, u32 win) | |||
1800 | void tipc_link_reset_stats(struct tipc_link *l) | 1807 | void tipc_link_reset_stats(struct tipc_link *l) |
1801 | { | 1808 | { |
1802 | memset(&l->stats, 0, sizeof(l->stats)); | 1809 | memset(&l->stats, 0, sizeof(l->stats)); |
1803 | if (!link_is_bc_sndlink(l)) { | ||
1804 | l->stats.sent_info = l->snd_nxt; | ||
1805 | l->stats.recv_info = l->rcv_nxt; | ||
1806 | } | ||
1807 | } | 1810 | } |
1808 | 1811 | ||
1809 | static void link_print(struct tipc_link *l, const char *str) | 1812 | static void link_print(struct tipc_link *l, const char *str) |
@@ -1867,12 +1870,12 @@ static int __tipc_nl_add_stats(struct sk_buff *skb, struct tipc_stats *s) | |||
1867 | }; | 1870 | }; |
1868 | 1871 | ||
1869 | struct nla_map map[] = { | 1872 | struct nla_map map[] = { |
1870 | {TIPC_NLA_STATS_RX_INFO, s->recv_info}, | 1873 | {TIPC_NLA_STATS_RX_INFO, 0}, |
1871 | {TIPC_NLA_STATS_RX_FRAGMENTS, s->recv_fragments}, | 1874 | {TIPC_NLA_STATS_RX_FRAGMENTS, s->recv_fragments}, |
1872 | {TIPC_NLA_STATS_RX_FRAGMENTED, s->recv_fragmented}, | 1875 | {TIPC_NLA_STATS_RX_FRAGMENTED, s->recv_fragmented}, |
1873 | {TIPC_NLA_STATS_RX_BUNDLES, s->recv_bundles}, | 1876 | {TIPC_NLA_STATS_RX_BUNDLES, s->recv_bundles}, |
1874 | {TIPC_NLA_STATS_RX_BUNDLED, s->recv_bundled}, | 1877 | {TIPC_NLA_STATS_RX_BUNDLED, s->recv_bundled}, |
1875 | {TIPC_NLA_STATS_TX_INFO, s->sent_info}, | 1878 | {TIPC_NLA_STATS_TX_INFO, 0}, |
1876 | {TIPC_NLA_STATS_TX_FRAGMENTS, s->sent_fragments}, | 1879 | {TIPC_NLA_STATS_TX_FRAGMENTS, s->sent_fragments}, |
1877 | {TIPC_NLA_STATS_TX_FRAGMENTED, s->sent_fragmented}, | 1880 | {TIPC_NLA_STATS_TX_FRAGMENTED, s->sent_fragmented}, |
1878 | {TIPC_NLA_STATS_TX_BUNDLES, s->sent_bundles}, | 1881 | {TIPC_NLA_STATS_TX_BUNDLES, s->sent_bundles}, |
@@ -1947,9 +1950,9 @@ int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg, | |||
1947 | goto attr_msg_full; | 1950 | goto attr_msg_full; |
1948 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_MTU, link->mtu)) | 1951 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_MTU, link->mtu)) |
1949 | goto attr_msg_full; | 1952 | goto attr_msg_full; |
1950 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, link->rcv_nxt)) | 1953 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, link->stats.recv_pkts)) |
1951 | goto attr_msg_full; | 1954 | goto attr_msg_full; |
1952 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, link->snd_nxt)) | 1955 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, link->stats.sent_pkts)) |
1953 | goto attr_msg_full; | 1956 | goto attr_msg_full; |
1954 | 1957 | ||
1955 | if (tipc_link_is_up(link)) | 1958 | if (tipc_link_is_up(link)) |
@@ -2004,12 +2007,12 @@ static int __tipc_nl_add_bc_link_stat(struct sk_buff *skb, | |||
2004 | }; | 2007 | }; |
2005 | 2008 | ||
2006 | struct nla_map map[] = { | 2009 | struct nla_map map[] = { |
2007 | {TIPC_NLA_STATS_RX_INFO, stats->recv_info}, | 2010 | {TIPC_NLA_STATS_RX_INFO, stats->recv_pkts}, |
2008 | {TIPC_NLA_STATS_RX_FRAGMENTS, stats->recv_fragments}, | 2011 | {TIPC_NLA_STATS_RX_FRAGMENTS, stats->recv_fragments}, |
2009 | {TIPC_NLA_STATS_RX_FRAGMENTED, stats->recv_fragmented}, | 2012 | {TIPC_NLA_STATS_RX_FRAGMENTED, stats->recv_fragmented}, |
2010 | {TIPC_NLA_STATS_RX_BUNDLES, stats->recv_bundles}, | 2013 | {TIPC_NLA_STATS_RX_BUNDLES, stats->recv_bundles}, |
2011 | {TIPC_NLA_STATS_RX_BUNDLED, stats->recv_bundled}, | 2014 | {TIPC_NLA_STATS_RX_BUNDLED, stats->recv_bundled}, |
2012 | {TIPC_NLA_STATS_TX_INFO, stats->sent_info}, | 2015 | {TIPC_NLA_STATS_TX_INFO, stats->sent_pkts}, |
2013 | {TIPC_NLA_STATS_TX_FRAGMENTS, stats->sent_fragments}, | 2016 | {TIPC_NLA_STATS_TX_FRAGMENTS, stats->sent_fragments}, |
2014 | {TIPC_NLA_STATS_TX_FRAGMENTED, stats->sent_fragmented}, | 2017 | {TIPC_NLA_STATS_TX_FRAGMENTED, stats->sent_fragmented}, |
2015 | {TIPC_NLA_STATS_TX_BUNDLES, stats->sent_bundles}, | 2018 | {TIPC_NLA_STATS_TX_BUNDLES, stats->sent_bundles}, |
@@ -2076,9 +2079,9 @@ int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg) | |||
2076 | goto attr_msg_full; | 2079 | goto attr_msg_full; |
2077 | if (nla_put_string(msg->skb, TIPC_NLA_LINK_NAME, bcl->name)) | 2080 | if (nla_put_string(msg->skb, TIPC_NLA_LINK_NAME, bcl->name)) |
2078 | goto attr_msg_full; | 2081 | goto attr_msg_full; |
2079 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, bcl->rcv_nxt)) | 2082 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, 0)) |
2080 | goto attr_msg_full; | 2083 | goto attr_msg_full; |
2081 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, bcl->snd_nxt)) | 2084 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, 0)) |
2082 | goto attr_msg_full; | 2085 | goto attr_msg_full; |
2083 | 2086 | ||
2084 | prop = nla_nest_start(msg->skb, TIPC_NLA_LINK_PROP); | 2087 | prop = nla_nest_start(msg->skb, TIPC_NLA_LINK_PROP); |
diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c index 78cab9c5a445..b58dc95f3d35 100644 --- a/net/tipc/udp_media.c +++ b/net/tipc/udp_media.c | |||
@@ -697,6 +697,11 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b, | |||
697 | udp_conf.local_ip.s_addr = htonl(INADDR_ANY); | 697 | udp_conf.local_ip.s_addr = htonl(INADDR_ANY); |
698 | udp_conf.use_udp_checksums = false; | 698 | udp_conf.use_udp_checksums = false; |
699 | ub->ifindex = dev->ifindex; | 699 | ub->ifindex = dev->ifindex; |
700 | if (tipc_mtu_bad(dev, sizeof(struct iphdr) + | ||
701 | sizeof(struct udphdr))) { | ||
702 | err = -EINVAL; | ||
703 | goto err; | ||
704 | } | ||
700 | b->mtu = dev->mtu - sizeof(struct iphdr) | 705 | b->mtu = dev->mtu - sizeof(struct iphdr) |
701 | - sizeof(struct udphdr); | 706 | - sizeof(struct udphdr); |
702 | #if IS_ENABLED(CONFIG_IPV6) | 707 | #if IS_ENABLED(CONFIG_IPV6) |