diff options
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/eth_media.c | 11 | ||||
-rw-r--r-- | net/tipc/link.c | 16 | ||||
-rw-r--r-- | net/tipc/port.c | 10 | ||||
-rw-r--r-- | net/tipc/port.h | 6 | ||||
-rw-r--r-- | net/tipc/socket.c | 80 |
5 files changed, 52 insertions, 71 deletions
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c index 77d2d9ce8962..711ca4b1f051 100644 --- a/net/tipc/eth_media.c +++ b/net/tipc/eth_media.c | |||
@@ -1,8 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * net/tipc/eth_media.c: Ethernet bearer support for TIPC | 2 | * net/tipc/eth_media.c: Ethernet bearer support for TIPC |
3 | * | 3 | * |
4 | * Copyright (c) 2001-2006, Ericsson AB | 4 | * Copyright (c) 2001-2007, Ericsson AB |
5 | * Copyright (c) 2005-2006, Wind River Systems | 5 | * Copyright (c) 2005-2007, Wind River Systems |
6 | * All rights reserved. | 6 | * All rights reserved. |
7 | * | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
@@ -87,6 +87,9 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr, | |||
87 | /** | 87 | /** |
88 | * recv_msg - handle incoming TIPC message from an Ethernet interface | 88 | * recv_msg - handle incoming TIPC message from an Ethernet interface |
89 | * | 89 | * |
90 | * Accept only packets explicitly sent to this node, or broadcast packets; | ||
91 | * ignores packets sent using Ethernet multicast, and traffic sent to other | ||
92 | * nodes (which can happen if interface is running in promiscuous mode). | ||
90 | * Routine truncates any Ethernet padding/CRC appended to the message, | 93 | * Routine truncates any Ethernet padding/CRC appended to the message, |
91 | * and ensures message size matches actual length | 94 | * and ensures message size matches actual length |
92 | */ | 95 | */ |
@@ -98,9 +101,7 @@ static int recv_msg(struct sk_buff *buf, struct net_device *dev, | |||
98 | u32 size; | 101 | u32 size; |
99 | 102 | ||
100 | if (likely(eb_ptr->bearer)) { | 103 | if (likely(eb_ptr->bearer)) { |
101 | if (likely(!dev->promiscuity) || | 104 | if (likely(buf->pkt_type <= PACKET_BROADCAST)) { |
102 | !memcmp(skb_mac_header(buf), dev->dev_addr, ETH_ALEN) || | ||
103 | !memcmp(skb_mac_header(buf), dev->broadcast, ETH_ALEN)) { | ||
104 | size = msg_size((struct tipc_msg *)buf->data); | 105 | size = msg_size((struct tipc_msg *)buf->data); |
105 | skb_trim(buf, size); | 106 | skb_trim(buf, size); |
106 | if (likely(buf->len == size)) { | 107 | if (likely(buf->len == size)) { |
diff --git a/net/tipc/link.c b/net/tipc/link.c index 2124f32ef29f..5adfdfd49d61 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
@@ -1,8 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * net/tipc/link.c: TIPC link code | 2 | * net/tipc/link.c: TIPC link code |
3 | * | 3 | * |
4 | * Copyright (c) 1996-2006, Ericsson AB | 4 | * Copyright (c) 1996-2007, Ericsson AB |
5 | * Copyright (c) 2004-2006, Wind River Systems | 5 | * Copyright (c) 2004-2007, Wind River Systems |
6 | * All rights reserved. | 6 | * All rights reserved. |
7 | * | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
@@ -1260,7 +1260,7 @@ again: | |||
1260 | * (Must not hold any locks while building message.) | 1260 | * (Must not hold any locks while building message.) |
1261 | */ | 1261 | */ |
1262 | 1262 | ||
1263 | res = msg_build(hdr, msg_sect, num_sect, sender->max_pkt, | 1263 | res = msg_build(hdr, msg_sect, num_sect, sender->publ.max_pkt, |
1264 | !sender->user_port, &buf); | 1264 | !sender->user_port, &buf); |
1265 | 1265 | ||
1266 | read_lock_bh(&tipc_net_lock); | 1266 | read_lock_bh(&tipc_net_lock); |
@@ -1271,7 +1271,7 @@ again: | |||
1271 | if (likely(l_ptr)) { | 1271 | if (likely(l_ptr)) { |
1272 | if (likely(buf)) { | 1272 | if (likely(buf)) { |
1273 | res = link_send_buf_fast(l_ptr, buf, | 1273 | res = link_send_buf_fast(l_ptr, buf, |
1274 | &sender->max_pkt); | 1274 | &sender->publ.max_pkt); |
1275 | if (unlikely(res < 0)) | 1275 | if (unlikely(res < 0)) |
1276 | buf_discard(buf); | 1276 | buf_discard(buf); |
1277 | exit: | 1277 | exit: |
@@ -1299,12 +1299,12 @@ exit: | |||
1299 | * then re-try fast path or fragment the message | 1299 | * then re-try fast path or fragment the message |
1300 | */ | 1300 | */ |
1301 | 1301 | ||
1302 | sender->max_pkt = link_max_pkt(l_ptr); | 1302 | sender->publ.max_pkt = link_max_pkt(l_ptr); |
1303 | tipc_node_unlock(node); | 1303 | tipc_node_unlock(node); |
1304 | read_unlock_bh(&tipc_net_lock); | 1304 | read_unlock_bh(&tipc_net_lock); |
1305 | 1305 | ||
1306 | 1306 | ||
1307 | if ((msg_hdr_sz(hdr) + res) <= sender->max_pkt) | 1307 | if ((msg_hdr_sz(hdr) + res) <= sender->publ.max_pkt) |
1308 | goto again; | 1308 | goto again; |
1309 | 1309 | ||
1310 | return link_send_sections_long(sender, msg_sect, | 1310 | return link_send_sections_long(sender, msg_sect, |
@@ -1357,7 +1357,7 @@ static int link_send_sections_long(struct port *sender, | |||
1357 | 1357 | ||
1358 | again: | 1358 | again: |
1359 | fragm_no = 1; | 1359 | fragm_no = 1; |
1360 | max_pkt = sender->max_pkt - INT_H_SIZE; | 1360 | max_pkt = sender->publ.max_pkt - INT_H_SIZE; |
1361 | /* leave room for tunnel header in case of link changeover */ | 1361 | /* leave room for tunnel header in case of link changeover */ |
1362 | fragm_sz = max_pkt - INT_H_SIZE; | 1362 | fragm_sz = max_pkt - INT_H_SIZE; |
1363 | /* leave room for fragmentation header in each fragment */ | 1363 | /* leave room for fragmentation header in each fragment */ |
@@ -1463,7 +1463,7 @@ error: | |||
1463 | goto reject; | 1463 | goto reject; |
1464 | } | 1464 | } |
1465 | if (link_max_pkt(l_ptr) < max_pkt) { | 1465 | if (link_max_pkt(l_ptr) < max_pkt) { |
1466 | sender->max_pkt = link_max_pkt(l_ptr); | 1466 | sender->publ.max_pkt = link_max_pkt(l_ptr); |
1467 | tipc_node_unlock(node); | 1467 | tipc_node_unlock(node); |
1468 | for (; buf_chain; buf_chain = buf) { | 1468 | for (; buf_chain; buf_chain = buf) { |
1469 | buf = buf_chain->next; | 1469 | buf = buf_chain->next; |
diff --git a/net/tipc/port.c b/net/tipc/port.c index bcd5da00737b..5d2b9ce84d0a 100644 --- a/net/tipc/port.c +++ b/net/tipc/port.c | |||
@@ -1,8 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * net/tipc/port.c: TIPC port code | 2 | * net/tipc/port.c: TIPC port code |
3 | * | 3 | * |
4 | * Copyright (c) 1992-2006, Ericsson AB | 4 | * Copyright (c) 1992-2007, Ericsson AB |
5 | * Copyright (c) 2004-2005, Wind River Systems | 5 | * Copyright (c) 2004-2007, Wind River Systems |
6 | * All rights reserved. | 6 | * All rights reserved. |
7 | * | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
@@ -239,6 +239,8 @@ u32 tipc_createport_raw(void *usr_handle, | |||
239 | } | 239 | } |
240 | 240 | ||
241 | tipc_port_lock(ref); | 241 | tipc_port_lock(ref); |
242 | p_ptr->publ.usr_handle = usr_handle; | ||
243 | p_ptr->publ.max_pkt = MAX_PKT_DEFAULT; | ||
242 | p_ptr->publ.ref = ref; | 244 | p_ptr->publ.ref = ref; |
243 | msg = &p_ptr->publ.phdr; | 245 | msg = &p_ptr->publ.phdr; |
244 | msg_init(msg, DATA_LOW, TIPC_NAMED_MSG, TIPC_OK, LONG_H_SIZE, 0); | 246 | msg_init(msg, DATA_LOW, TIPC_NAMED_MSG, TIPC_OK, LONG_H_SIZE, 0); |
@@ -248,11 +250,9 @@ u32 tipc_createport_raw(void *usr_handle, | |||
248 | msg_set_importance(msg,importance); | 250 | msg_set_importance(msg,importance); |
249 | p_ptr->last_in_seqno = 41; | 251 | p_ptr->last_in_seqno = 41; |
250 | p_ptr->sent = 1; | 252 | p_ptr->sent = 1; |
251 | p_ptr->publ.usr_handle = usr_handle; | ||
252 | INIT_LIST_HEAD(&p_ptr->wait_list); | 253 | INIT_LIST_HEAD(&p_ptr->wait_list); |
253 | INIT_LIST_HEAD(&p_ptr->subscription.nodesub_list); | 254 | INIT_LIST_HEAD(&p_ptr->subscription.nodesub_list); |
254 | p_ptr->congested_link = NULL; | 255 | p_ptr->congested_link = NULL; |
255 | p_ptr->max_pkt = MAX_PKT_DEFAULT; | ||
256 | p_ptr->dispatcher = dispatcher; | 256 | p_ptr->dispatcher = dispatcher; |
257 | p_ptr->wakeup = wakeup; | 257 | p_ptr->wakeup = wakeup; |
258 | p_ptr->user_port = NULL; | 258 | p_ptr->user_port = NULL; |
@@ -1243,7 +1243,7 @@ int tipc_connect2port(u32 ref, struct tipc_portid const *peer) | |||
1243 | res = TIPC_OK; | 1243 | res = TIPC_OK; |
1244 | exit: | 1244 | exit: |
1245 | tipc_port_unlock(p_ptr); | 1245 | tipc_port_unlock(p_ptr); |
1246 | p_ptr->max_pkt = tipc_link_get_max_pkt(peer->node, ref); | 1246 | p_ptr->publ.max_pkt = tipc_link_get_max_pkt(peer->node, ref); |
1247 | return res; | 1247 | return res; |
1248 | } | 1248 | } |
1249 | 1249 | ||
diff --git a/net/tipc/port.h b/net/tipc/port.h index 7ef4d64b32f7..e5f8c16429bd 100644 --- a/net/tipc/port.h +++ b/net/tipc/port.h | |||
@@ -1,8 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * net/tipc/port.h: Include file for TIPC port code | 2 | * net/tipc/port.h: Include file for TIPC port code |
3 | * | 3 | * |
4 | * Copyright (c) 1994-2006, Ericsson AB | 4 | * Copyright (c) 1994-2007, Ericsson AB |
5 | * Copyright (c) 2004-2005, Wind River Systems | 5 | * Copyright (c) 2004-2007, Wind River Systems |
6 | * All rights reserved. | 6 | * All rights reserved. |
7 | * | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
@@ -81,7 +81,6 @@ struct user_port { | |||
81 | * @acked: | 81 | * @acked: |
82 | * @publications: list of publications for port | 82 | * @publications: list of publications for port |
83 | * @pub_count: total # of publications port has made during its lifetime | 83 | * @pub_count: total # of publications port has made during its lifetime |
84 | * @max_pkt: maximum packet size "hint" used when building messages sent by port | ||
85 | * @probing_state: | 84 | * @probing_state: |
86 | * @probing_interval: | 85 | * @probing_interval: |
87 | * @last_in_seqno: | 86 | * @last_in_seqno: |
@@ -102,7 +101,6 @@ struct port { | |||
102 | u32 acked; | 101 | u32 acked; |
103 | struct list_head publications; | 102 | struct list_head publications; |
104 | u32 pub_count; | 103 | u32 pub_count; |
105 | u32 max_pkt; | ||
106 | u32 probing_state; | 104 | u32 probing_state; |
107 | u32 probing_interval; | 105 | u32 probing_interval; |
108 | u32 last_in_seqno; | 106 | u32 last_in_seqno; |
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index 45832fb75ea4..4a8f37f48764 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
@@ -1,8 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * net/tipc/socket.c: TIPC socket API | 2 | * net/tipc/socket.c: TIPC socket API |
3 | * | 3 | * |
4 | * Copyright (c) 2001-2006, Ericsson AB | 4 | * Copyright (c) 2001-2007, Ericsson AB |
5 | * Copyright (c) 2004-2006, Wind River Systems | 5 | * Copyright (c) 2004-2007, Wind River Systems |
6 | * All rights reserved. | 6 | * All rights reserved. |
7 | * | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
@@ -607,23 +607,24 @@ exit: | |||
607 | static int send_stream(struct kiocb *iocb, struct socket *sock, | 607 | static int send_stream(struct kiocb *iocb, struct socket *sock, |
608 | struct msghdr *m, size_t total_len) | 608 | struct msghdr *m, size_t total_len) |
609 | { | 609 | { |
610 | struct tipc_port *tport; | ||
610 | struct msghdr my_msg; | 611 | struct msghdr my_msg; |
611 | struct iovec my_iov; | 612 | struct iovec my_iov; |
612 | struct iovec *curr_iov; | 613 | struct iovec *curr_iov; |
613 | int curr_iovlen; | 614 | int curr_iovlen; |
614 | char __user *curr_start; | 615 | char __user *curr_start; |
616 | u32 hdr_size; | ||
615 | int curr_left; | 617 | int curr_left; |
616 | int bytes_to_send; | 618 | int bytes_to_send; |
617 | int bytes_sent; | 619 | int bytes_sent; |
618 | int res; | 620 | int res; |
619 | 621 | ||
620 | if (likely(total_len <= TIPC_MAX_USER_MSG_SIZE)) | 622 | /* Handle special cases where there is no connection */ |
621 | return send_packet(iocb, sock, m, total_len); | ||
622 | |||
623 | /* Can only send large data streams if already connected */ | ||
624 | 623 | ||
625 | if (unlikely(sock->state != SS_CONNECTED)) { | 624 | if (unlikely(sock->state != SS_CONNECTED)) { |
626 | if (sock->state == SS_DISCONNECTING) | 625 | if (sock->state == SS_UNCONNECTED) |
626 | return send_packet(iocb, sock, m, total_len); | ||
627 | else if (sock->state == SS_DISCONNECTING) | ||
627 | return -EPIPE; | 628 | return -EPIPE; |
628 | else | 629 | else |
629 | return -ENOTCONN; | 630 | return -ENOTCONN; |
@@ -648,17 +649,25 @@ static int send_stream(struct kiocb *iocb, struct socket *sock, | |||
648 | my_msg.msg_name = NULL; | 649 | my_msg.msg_name = NULL; |
649 | bytes_sent = 0; | 650 | bytes_sent = 0; |
650 | 651 | ||
652 | tport = tipc_sk(sock->sk)->p; | ||
653 | hdr_size = msg_hdr_sz(&tport->phdr); | ||
654 | |||
651 | while (curr_iovlen--) { | 655 | while (curr_iovlen--) { |
652 | curr_start = curr_iov->iov_base; | 656 | curr_start = curr_iov->iov_base; |
653 | curr_left = curr_iov->iov_len; | 657 | curr_left = curr_iov->iov_len; |
654 | 658 | ||
655 | while (curr_left) { | 659 | while (curr_left) { |
656 | bytes_to_send = (curr_left < TIPC_MAX_USER_MSG_SIZE) | 660 | bytes_to_send = tport->max_pkt - hdr_size; |
657 | ? curr_left : TIPC_MAX_USER_MSG_SIZE; | 661 | if (bytes_to_send > TIPC_MAX_USER_MSG_SIZE) |
662 | bytes_to_send = TIPC_MAX_USER_MSG_SIZE; | ||
663 | if (curr_left < bytes_to_send) | ||
664 | bytes_to_send = curr_left; | ||
658 | my_iov.iov_base = curr_start; | 665 | my_iov.iov_base = curr_start; |
659 | my_iov.iov_len = bytes_to_send; | 666 | my_iov.iov_len = bytes_to_send; |
660 | if ((res = send_packet(iocb, sock, &my_msg, 0)) < 0) { | 667 | if ((res = send_packet(iocb, sock, &my_msg, 0)) < 0) { |
661 | return bytes_sent ? bytes_sent : res; | 668 | if (bytes_sent != 0) |
669 | res = bytes_sent; | ||
670 | return res; | ||
662 | } | 671 | } |
663 | curr_left -= bytes_to_send; | 672 | curr_left -= bytes_to_send; |
664 | curr_start += bytes_to_send; | 673 | curr_start += bytes_to_send; |
@@ -1600,33 +1609,6 @@ static int getsockopt(struct socket *sock, | |||
1600 | } | 1609 | } |
1601 | 1610 | ||
1602 | /** | 1611 | /** |
1603 | * Placeholders for non-implemented functionality | ||
1604 | * | ||
1605 | * Returns error code (POSIX-compliant where defined) | ||
1606 | */ | ||
1607 | |||
1608 | static int ioctl(struct socket *s, u32 cmd, unsigned long arg) | ||
1609 | { | ||
1610 | return -EINVAL; | ||
1611 | } | ||
1612 | |||
1613 | static int no_mmap(struct file *file, struct socket *sock, | ||
1614 | struct vm_area_struct *vma) | ||
1615 | { | ||
1616 | return -EINVAL; | ||
1617 | } | ||
1618 | static ssize_t no_sendpage(struct socket *sock, struct page *page, | ||
1619 | int offset, size_t size, int flags) | ||
1620 | { | ||
1621 | return -EINVAL; | ||
1622 | } | ||
1623 | |||
1624 | static int no_skpair(struct socket *s1, struct socket *s2) | ||
1625 | { | ||
1626 | return -EOPNOTSUPP; | ||
1627 | } | ||
1628 | |||
1629 | /** | ||
1630 | * Protocol switches for the various types of TIPC sockets | 1612 | * Protocol switches for the various types of TIPC sockets |
1631 | */ | 1613 | */ |
1632 | 1614 | ||
@@ -1636,19 +1618,19 @@ static struct proto_ops msg_ops = { | |||
1636 | .release = release, | 1618 | .release = release, |
1637 | .bind = bind, | 1619 | .bind = bind, |
1638 | .connect = connect, | 1620 | .connect = connect, |
1639 | .socketpair = no_skpair, | 1621 | .socketpair = sock_no_socketpair, |
1640 | .accept = accept, | 1622 | .accept = accept, |
1641 | .getname = get_name, | 1623 | .getname = get_name, |
1642 | .poll = poll, | 1624 | .poll = poll, |
1643 | .ioctl = ioctl, | 1625 | .ioctl = sock_no_ioctl, |
1644 | .listen = listen, | 1626 | .listen = listen, |
1645 | .shutdown = shutdown, | 1627 | .shutdown = shutdown, |
1646 | .setsockopt = setsockopt, | 1628 | .setsockopt = setsockopt, |
1647 | .getsockopt = getsockopt, | 1629 | .getsockopt = getsockopt, |
1648 | .sendmsg = send_msg, | 1630 | .sendmsg = send_msg, |
1649 | .recvmsg = recv_msg, | 1631 | .recvmsg = recv_msg, |
1650 | .mmap = no_mmap, | 1632 | .mmap = sock_no_mmap, |
1651 | .sendpage = no_sendpage | 1633 | .sendpage = sock_no_sendpage |
1652 | }; | 1634 | }; |
1653 | 1635 | ||
1654 | static struct proto_ops packet_ops = { | 1636 | static struct proto_ops packet_ops = { |
@@ -1657,19 +1639,19 @@ static struct proto_ops packet_ops = { | |||
1657 | .release = release, | 1639 | .release = release, |
1658 | .bind = bind, | 1640 | .bind = bind, |
1659 | .connect = connect, | 1641 | .connect = connect, |
1660 | .socketpair = no_skpair, | 1642 | .socketpair = sock_no_socketpair, |
1661 | .accept = accept, | 1643 | .accept = accept, |
1662 | .getname = get_name, | 1644 | .getname = get_name, |
1663 | .poll = poll, | 1645 | .poll = poll, |
1664 | .ioctl = ioctl, | 1646 | .ioctl = sock_no_ioctl, |
1665 | .listen = listen, | 1647 | .listen = listen, |
1666 | .shutdown = shutdown, | 1648 | .shutdown = shutdown, |
1667 | .setsockopt = setsockopt, | 1649 | .setsockopt = setsockopt, |
1668 | .getsockopt = getsockopt, | 1650 | .getsockopt = getsockopt, |
1669 | .sendmsg = send_packet, | 1651 | .sendmsg = send_packet, |
1670 | .recvmsg = recv_msg, | 1652 | .recvmsg = recv_msg, |
1671 | .mmap = no_mmap, | 1653 | .mmap = sock_no_mmap, |
1672 | .sendpage = no_sendpage | 1654 | .sendpage = sock_no_sendpage |
1673 | }; | 1655 | }; |
1674 | 1656 | ||
1675 | static struct proto_ops stream_ops = { | 1657 | static struct proto_ops stream_ops = { |
@@ -1678,19 +1660,19 @@ static struct proto_ops stream_ops = { | |||
1678 | .release = release, | 1660 | .release = release, |
1679 | .bind = bind, | 1661 | .bind = bind, |
1680 | .connect = connect, | 1662 | .connect = connect, |
1681 | .socketpair = no_skpair, | 1663 | .socketpair = sock_no_socketpair, |
1682 | .accept = accept, | 1664 | .accept = accept, |
1683 | .getname = get_name, | 1665 | .getname = get_name, |
1684 | .poll = poll, | 1666 | .poll = poll, |
1685 | .ioctl = ioctl, | 1667 | .ioctl = sock_no_ioctl, |
1686 | .listen = listen, | 1668 | .listen = listen, |
1687 | .shutdown = shutdown, | 1669 | .shutdown = shutdown, |
1688 | .setsockopt = setsockopt, | 1670 | .setsockopt = setsockopt, |
1689 | .getsockopt = getsockopt, | 1671 | .getsockopt = getsockopt, |
1690 | .sendmsg = send_stream, | 1672 | .sendmsg = send_stream, |
1691 | .recvmsg = recv_stream, | 1673 | .recvmsg = recv_stream, |
1692 | .mmap = no_mmap, | 1674 | .mmap = sock_no_mmap, |
1693 | .sendpage = no_sendpage | 1675 | .sendpage = sock_no_sendpage |
1694 | }; | 1676 | }; |
1695 | 1677 | ||
1696 | static struct net_proto_family tipc_family_ops = { | 1678 | static struct net_proto_family tipc_family_ops = { |