Skip to content

Commit 14a98e6

Browse files
committed
Merge branch 'tipc-socketpair'
Parthasarathy Bhuvaragan says: ==================== tipc: add socketpair support We add socketpair support for connection oriented sockets in the first patch and for connection less in the second. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents d6956ac + 66bc1e8 commit 14a98e6

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

net/tipc/socket.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2511,6 +2511,28 @@ static int tipc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
25112511
}
25122512
}
25132513

2514+
static int tipc_socketpair(struct socket *sock1, struct socket *sock2)
2515+
{
2516+
struct tipc_sock *tsk2 = tipc_sk(sock2->sk);
2517+
struct tipc_sock *tsk1 = tipc_sk(sock1->sk);
2518+
u32 onode = tipc_own_addr(sock_net(sock1->sk));
2519+
2520+
tsk1->peer.family = AF_TIPC;
2521+
tsk1->peer.addrtype = TIPC_ADDR_ID;
2522+
tsk1->peer.scope = TIPC_NODE_SCOPE;
2523+
tsk1->peer.addr.id.ref = tsk2->portid;
2524+
tsk1->peer.addr.id.node = onode;
2525+
tsk2->peer.family = AF_TIPC;
2526+
tsk2->peer.addrtype = TIPC_ADDR_ID;
2527+
tsk2->peer.scope = TIPC_NODE_SCOPE;
2528+
tsk2->peer.addr.id.ref = tsk1->portid;
2529+
tsk2->peer.addr.id.node = onode;
2530+
2531+
tipc_sk_finish_conn(tsk1, tsk2->portid, onode);
2532+
tipc_sk_finish_conn(tsk2, tsk1->portid, onode);
2533+
return 0;
2534+
}
2535+
25142536
/* Protocol switches for the various types of TIPC sockets */
25152537

25162538
static const struct proto_ops msg_ops = {
@@ -2519,7 +2541,7 @@ static const struct proto_ops msg_ops = {
25192541
.release = tipc_release,
25202542
.bind = tipc_bind,
25212543
.connect = tipc_connect,
2522-
.socketpair = sock_no_socketpair,
2544+
.socketpair = tipc_socketpair,
25232545
.accept = sock_no_accept,
25242546
.getname = tipc_getname,
25252547
.poll = tipc_poll,
@@ -2540,7 +2562,7 @@ static const struct proto_ops packet_ops = {
25402562
.release = tipc_release,
25412563
.bind = tipc_bind,
25422564
.connect = tipc_connect,
2543-
.socketpair = sock_no_socketpair,
2565+
.socketpair = tipc_socketpair,
25442566
.accept = tipc_accept,
25452567
.getname = tipc_getname,
25462568
.poll = tipc_poll,
@@ -2561,7 +2583,7 @@ static const struct proto_ops stream_ops = {
25612583
.release = tipc_release,
25622584
.bind = tipc_bind,
25632585
.connect = tipc_connect,
2564-
.socketpair = sock_no_socketpair,
2586+
.socketpair = tipc_socketpair,
25652587
.accept = tipc_accept,
25662588
.getname = tipc_getname,
25672589
.poll = tipc_poll,

0 commit comments

Comments
 (0)