1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
|
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <fs/devfs.h>
#include <fs/tmpfs.h>
#include <interrupts.h>
#include <lib/ringbuffer.h>
#include <math.h>
#include <network/bytes.h>
#include <network/tcp.h>
#include <network/udp.h>
#include <poll.h>
#include <sched/scheduler.h>
#include <socket.h>
#include <stdatomic.h>
#include <sys/socket.h>
struct list open_udp_connections;
struct relist open_tcp_connections;
void global_socket_init(void) {
list_init(&open_udp_connections);
relist_init(&open_tcp_connections);
}
OPEN_UNIX_SOCKET *un_sockets[100] = {0};
void gen_ipv4(ipv4_t *ip, u8 i1, u8 i2, u8 i3, u8 i4) {
ip->d = (i1 << (8 * 0)) | (i2 << (8 * 1)) | (i3 << (8 * 2)) | (i4 << (8 * 3));
}
void tcp_remove_connection(struct TcpConnection *con) {
// TODO: It should also be freed but I am unsure if a inode might
// still have a pointer(that should not be the case)
for (int i = 0;; i++) {
struct TcpConnection *c;
int end;
if (!relist_get(&open_tcp_connections, i, (void **)&c, &end)) {
if (end) {
break;
}
continue;
}
if (c == con) {
relist_remove(&open_tcp_connections, i);
break;
}
}
}
struct TcpConnection *tcp_find_connection(ipv4_t src_ip, u16 src_port,
ipv4_t dst_ip, u16 dst_port) {
for (int i = 0;; i++) {
struct TcpConnection *c;
int end;
if (!relist_get(&open_tcp_connections, i, (void **)&c, &end)) {
if (end) {
break;
}
continue;
}
if (TCP_STATE_CLOSED == c->state) {
continue;
}
if (c->incoming_port == dst_port && c->outgoing_port == src_port) {
return c;
}
}
return NULL;
}
int tcp_sync_buffer(struct TcpConnection *con);
void tcp_flush_buffers(void) {
for (int i = 0;; i++) {
struct TcpConnection *c;
int end;
if (!relist_get(&open_tcp_connections, i, (void **)&c, &end)) {
if (end) {
break;
}
continue;
}
if (TCP_STATE_CLOSED == c->state) {
continue;
}
tcp_sync_buffer(c);
}
}
void tcp_flush_acks(void) {
for (int i = 0;; i++) {
struct TcpConnection *c;
int end;
if (!relist_get(&open_tcp_connections, i, (void **)&c, &end)) {
if (end) {
break;
}
continue;
}
if (TCP_STATE_CLOSED == c->state) {
continue;
}
if (!c->should_send_ack) {
continue;
}
c->should_send_ack = 0;
tcp_send_empty_payload(c, ACK);
}
}
u16 tcp_find_free_port(u16 suggestion) {
for (int i = 0;; i++) {
struct TcpConnection *c;
int end;
if (!relist_get(&open_tcp_connections, i, (void **)&c, &end)) {
if (end) {
break;
}
continue;
}
if (c->incoming_port == suggestion) {
suggestion++;
// FIXME: Recursion bad
return tcp_find_free_port(suggestion);
}
}
return suggestion;
}
struct UdpConnection *udp_find_connection(ipv4_t src_ip, u16 src_port,
u16 dst_port) {
(void)src_ip;
for (int i = 0;; i++) {
struct UdpConnection *c;
if (!list_get(&open_udp_connections, i, (void **)&c)) {
break;
}
if (c->dead) {
continue;
}
if (c->incoming_port == dst_port && c->outgoing_port == src_port) {
return c;
}
}
return NULL;
}
int tcp_sync_buffer(struct TcpConnection *con) {
if (TCP_STATE_CLOSED == con->state) {
return 0;
}
struct ringbuffer *rb = &con->outgoing_buffer;
u32 send_buffer_len = ringbuffer_used(rb);
if (0 == send_buffer_len) {
return 0;
}
u32 len = min(tcp_can_send(con), send_buffer_len);
char *send_buffer = kmalloc(len);
assert(ringbuffer_read(rb, send_buffer, len) == len);
send_tcp_packet(con, send_buffer, len);
kfree(send_buffer);
if (len < send_buffer_len) {
return 0;
} else {
return 1;
}
}
void tcp_close(vfs_fd_t *fd) {
struct TcpConnection *con = fd->inode->internal_object;
assert(con);
tcp_sync_buffer(con);
tcp_close_connection(con);
}
int tcp_read(u8 *buffer, u64 offset, u64 len, vfs_fd_t *fd) {
struct TcpConnection *con = fd->inode->internal_object;
assert(con);
u32 rc = ringbuffer_read(&con->incoming_buffer, buffer, len);
if (0 == rc && len > 0) {
if (TCP_STATE_ESTABLISHED != con->state) {
return -ENOTCONN;
}
return -EWOULDBLOCK;
}
return rc;
}
int tcp_has_data(vfs_inode_t *inode) {
struct TcpConnection *con = inode->internal_object;
return !(ringbuffer_isempty(&con->incoming_buffer));
}
int tcp_can_write(vfs_inode_t *inode) {
struct TcpConnection *con = inode->internal_object;
if (con->no_delay) {
return (0 != tcp_can_send(con));
}
return (ringbuffer_unused(&con->outgoing_buffer) > 0) ||
(0 != tcp_can_send(con));
}
int tcp_write(u8 *buffer, u64 offset, u64 len, vfs_fd_t *fd) {
(void)offset;
struct TcpConnection *con = fd->inode->internal_object;
assert(con);
if (TCP_STATE_ESTABLISHED != con->state) {
return -ENOTCONN;
}
if (!tcp_can_write(fd->inode)) {
return -EWOULDBLOCK;
}
len = min(len, tcp_can_send(con));
if (0 == len) {
return -EWOULDBLOCK;
}
if (con->no_delay) {
if (!send_tcp_packet(con, buffer, len)) {
return -EWOULDBLOCK;
}
return len;
}
struct ringbuffer *rb = &con->outgoing_buffer;
if (ringbuffer_unused(rb) < len) {
if (!tcp_sync_buffer(con)) {
return 0;
}
if (!send_tcp_packet(con, buffer, len)) {
return -EWOULDBLOCK;
}
} else {
assert(ringbuffer_write(rb, buffer, len) == len);
}
return len;
}
int udp_recvfrom(vfs_fd_t *fd, void *buffer, size_t len, int flags,
struct sockaddr *src_addr, socklen_t *addrlen) {
struct UdpConnection *con = fd->inode->internal_object;
assert(con);
if (con->dead) {
return -EBADF; // TODO: Check if this is correct.
}
u32 packet_length;
u32 rc = ringbuffer_read(&con->incoming_buffer, (void *)&packet_length,
sizeof(u32));
if (0 == rc) {
return -EWOULDBLOCK;
}
assert(sizeof(u32) == rc);
assert(sizeof(struct sockaddr_in) <= packet_length);
struct sockaddr_in from;
ringbuffer_read(&con->incoming_buffer, (void *)&from, sizeof(from));
if (addrlen) {
if (src_addr) {
memcpy(src_addr, &from, min(sizeof(from), *addrlen));
}
*addrlen = sizeof(from);
}
u32 rest = packet_length - sizeof(from);
u32 to_read = min(rest, len);
rest = rest - to_read;
rc = ringbuffer_read(&con->incoming_buffer, buffer, to_read);
// Discard the rest of the packet
// FIXME Maybe the rest of the packet can be kept? But unsure how that
// would be done while preserving the header and not messing up other
// packets.
(void)ringbuffer_read(&con->incoming_buffer, NULL, rest);
return rc;
}
int udp_read(u8 *buffer, u64 offset, u64 len, vfs_fd_t *fd) {
return udp_recvfrom(fd, buffer, len, 0, NULL, NULL);
}
int udp_write(u8 *buffer, u64 offset, u64 len, vfs_fd_t *fd) {
(void)offset;
struct UdpConnection *con = fd->inode->internal_object;
assert(con);
if (con->dead) {
return -EBADF; // TODO: Check if this is correct.
}
struct sockaddr_in dst;
dst.sin_addr.s_addr = con->outgoing_ip;
dst.sin_port = htons(con->outgoing_port);
struct sockaddr_in src;
src.sin_addr.s_addr = con->incoming_ip;
src.sin_port = htons(con->incoming_port);
send_udp_packet(&src, &dst, buffer, (u16)len);
return len;
}
int udp_has_data(vfs_inode_t *inode) {
struct UdpConnection *con = inode->internal_object;
return !(ringbuffer_isempty(&con->incoming_buffer));
}
void udp_close(vfs_fd_t *fd) {
struct UdpConnection *con = fd->inode->internal_object;
con->dead = 1;
return;
}
int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) {
vfs_fd_t *fd = get_vfs_fd(sockfd, NULL);
if (!fd) {
return -EBADF;
}
assert(fd->inode);
assert(fd->inode->connect);
return fd->inode->connect(fd, addr, addrlen);
}
int udp_connect(vfs_fd_t *fd, const struct sockaddr *addr, socklen_t addrlen) {
assert(AF_INET == addr->sa_family);
const struct sockaddr_in *in_addr = (const struct sockaddr_in *)addr;
struct UdpConnection *con = kcalloc(1, sizeof(struct UdpConnection));
if (!con) {
return -ENOMEM;
}
con->incoming_port = 1337; // TODO
con->outgoing_ip = in_addr->sin_addr.s_addr;
con->outgoing_port = ntohs(in_addr->sin_port);
assert(ringbuffer_init(&con->incoming_buffer, 8192));
assert(list_add(&open_udp_connections, con, NULL));
fd->inode->_has_data = udp_has_data;
fd->inode->write = udp_write;
fd->inode->read = udp_read;
fd->inode->close = udp_close;
fd->inode->internal_object = con;
return 0;
}
int tcp_connect(vfs_fd_t *fd, const struct sockaddr *addr, socklen_t addrlen) {
struct TcpConnection *con = fd->inode->internal_object;
assert(AF_INET == addr->sa_family);
const struct sockaddr_in *in_addr = (const struct sockaddr_in *)addr;
con->state = TCP_STATE_LISTEN;
con->incoming_port = tcp_find_free_port(1337);
con->outgoing_ip = in_addr->sin_addr.s_addr;
con->outgoing_port = ntohs(in_addr->sin_port);
con->max_seg = 1;
con->rcv_wnd = 65535;
con->rcv_nxt = 0;
con->rcv_adv = 0;
con->snd_una = 0;
con->snd_nxt = 0;
con->snd_max = 0;
con->snd_wnd = 0;
con->sent_ack = 0;
ringbuffer_init(&con->incoming_buffer, con->rcv_wnd * 64);
ringbuffer_init(&con->outgoing_buffer, 8192);
con->snd_wnd = ringbuffer_unused(&con->outgoing_buffer);
relist_add(&open_tcp_connections, con, NULL);
con->state = TCP_STATE_SYN_SENT;
tcp_send_empty_payload(con, SYN);
if (!(O_NONBLOCK & fd->flags)) {
for (;;) {
switch_task();
if (TCP_STATE_CLOSED == con->state) {
return -ECONNREFUSED;
}
if (TCP_STATE_ESTABLISHED == con->state) {
break;
}
assert(TCP_STATE_SYN_SENT == con->state ||
TCP_STATE_ESTABLISHED == con->state);
}
}
fd->inode->_has_data = tcp_has_data;
fd->inode->_can_write = tcp_can_write;
fd->inode->write = tcp_write;
fd->inode->read = tcp_read;
fd->inode->close = tcp_close;
fd->inode->internal_object = con;
return 0;
}
int setsockopt(int socket, int level, int option_name, const void *option_value,
socklen_t option_len) {
vfs_fd_t *fd = get_vfs_fd(socket, NULL);
if (!fd) {
return -EBADF;
}
// TODO: Check that it is actually a TCP socket
if (IPPROTO_TCP == level) {
struct TcpConnection *tcp_connection = fd->inode->internal_object;
switch (option_name) {
case TCP_NODELAY: {
if (sizeof(int) != option_len) {
return -EINVAL;
}
if (!mmu_is_valid_userpointer(option_value, option_len)) {
return -EPERM; // TODO: Check if this is correct
}
int value = *(int *)option_value;
tcp_connection->no_delay = value;
} break;
default:
return -ENOPROTOOPT;
break;
}
return 0;
}
return -ENOPROTOOPT;
}
int uds_open(const char *path) {
// FIXME: This is super ugly
// Find the socket that path belongs to
SOCKET *s = NULL;
for (int i = 0; i < 100; i++) {
if (!un_sockets[i]) {
continue;
}
const char *p = path;
const char *e = p;
for (; *e; e++)
;
for (; e != p && *e != '/'; e--)
;
if (0 == strcmp(e, un_sockets[i]->path)) {
s = un_sockets[i]->s;
break;
}
}
if (!s) {
return -1;
}
// Create a pipe
int fd[2];
dual_pipe(fd);
char c = 'i';
fifo_object_write((u8 *)&c, 1, 0, s->fifo_file);
s->incoming_fd = get_vfs_fd(fd[1], NULL);
s->incoming_fd->reference_count++;
vfs_close(fd[1]);
return fd[0];
}
int tcp_listen_has_data(vfs_inode_t *inode) {
const SOCKET *s = (SOCKET *)inode->internal_object;
const struct TcpListen *tcp_listen = s->object;
return !stack_isempty(&tcp_listen->incoming_connections);
}
int accept(int socket, struct sockaddr *address, socklen_t *address_len) {
(void)address;
(void)address_len;
vfs_fd_t *fd_ptr = get_vfs_fd(socket, NULL);
assert(fd_ptr);
vfs_inode_t *inode = fd_ptr->inode;
SOCKET *s = (SOCKET *)inode->internal_object;
if (AF_UNIX == s->domain) {
for (; NULL == s->incoming_fd;) {
// Wait until we have gotten a connection
struct pollfd fds[1];
fds[0].fd = socket;
fds[0].events = POLLIN;
fds[0].revents = 0;
poll(fds, 1, 0);
}
int index;
assert(relist_add(¤t_task->file_descriptors, s->incoming_fd, &index));
assert(1 <= s->incoming_fd->reference_count);
s->incoming_fd = NULL;
return index;
}
if (AF_INET == s->domain) {
struct TcpListen *tcp_listen = s->object;
assert(tcp_listen);
if (stack_isempty(&tcp_listen->incoming_connections)) {
if (fd_ptr->flags & O_NONBLOCK) {
return -EWOULDBLOCK;
}
struct pollfd fds[1];
fds[0].fd = socket;
fds[0].events = POLLIN;
fds[0].revents = 0;
poll(fds, 1, 0);
}
struct TcpConnection *connection =
stack_pop(&tcp_listen->incoming_connections);
assert(connection);
vfs_inode_t *inode = vfs_create_inode(
0 /*inode_num*/, FS_TYPE_UNIX_SOCKET, tcp_has_data, tcp_can_write, 1,
connection, 0 /*file_size*/, NULL /*open*/, NULL /*create_file*/,
tcp_read, tcp_write, tcp_close /*close*/, NULL /*create_directory*/,
NULL /*get_vm_object*/, NULL /*truncate*/, NULL /*stat*/,
NULL /*send_signal*/, NULL /*connect*/);
assert(inode);
return vfs_create_fd(O_RDWR, 0, 0 /*is_tty*/, inode, NULL);
}
ASSERT_NOT_REACHED;
return 0;
}
int bind_has_data(vfs_inode_t *inode) {
SOCKET *socket = inode->internal_object;
return socket->incoming_fd;
}
int bind_can_write(vfs_inode_t *inode) {
(void)inode;
return 1;
}
int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen) {
(void)addrlen;
vfs_fd_t *fd = get_vfs_fd(sockfd, NULL);
if (!fd) {
return -EBADF;
}
vfs_inode_t *inode = fd->inode;
if (!inode) {
return -EBADF;
}
if (FS_TYPE_UNIX_SOCKET != inode->type) {
return -ENOTSOCK;
}
SOCKET *s = (SOCKET *)inode->internal_object;
if (AF_UNIX == s->domain) {
struct sockaddr_un *un = (struct sockaddr_un *)addr;
size_t path_len = strlen(un->sun_path);
s->path = kmalloc(path_len + 1);
memcpy(s->path, un->sun_path, path_len);
s->path[path_len] = '\0';
OPEN_UNIX_SOCKET *us;
int i = 0;
for (; i < 100; i++) {
if (!un_sockets[i]) {
break;
}
}
us = un_sockets[i] = kmalloc(sizeof(OPEN_UNIX_SOCKET));
us->path = s->path;
us->s = s;
s->child = us;
devfs_add_file(us->path, NULL, NULL, NULL, NULL, bind_can_write,
FS_TYPE_UNIX_SOCKET);
return 0;
} else if (AF_INET == s->domain) {
assert(0);
return 0;
}
ASSERT_NOT_REACHED;
}
int socket_has_data(vfs_inode_t *inode) {
SOCKET *s = (SOCKET *)inode->internal_object;
FIFO_FILE *file = s->fifo_file;
return file->has_data;
}
int socket_can_write(vfs_inode_t *inode) {
(void)inode;
return 1;
}
int socket_write(u8 *buffer, u64 offset, u64 len, vfs_fd_t *fd) {
SOCKET *s = (SOCKET *)fd->inode->internal_object;
FIFO_FILE *file = s->fifo_file;
return fifo_object_write(buffer, 0, len, file);
}
int socket_read(u8 *buffer, u64 offset, u64 len, vfs_fd_t *fd) {
SOCKET *s = (SOCKET *)fd->inode->internal_object;
FIFO_FILE *file = s->fifo_file;
return fifo_object_read(buffer, 0, len, file);
}
void socket_close(vfs_fd_t *fd) {
fd->inode->is_open = 0;
}
int tcp_create_fd(int is_nonblock) {
struct TcpConnection *con = kmalloc(sizeof(struct TcpConnection));
if (!con) {
return -ENOMEM;
}
memset(con, 0, sizeof(struct TcpConnection));
con->state = TCP_STATE_CLOSED;
con->should_send_ack = 0;
vfs_inode_t *inode = vfs_create_inode(
0 /*inode_num*/, FS_TYPE_UNIX_SOCKET, NULL, always_can_write, 1, con,
0 /*file_size*/, NULL /*open*/, NULL /*create_file*/, tcp_read, tcp_write,
NULL /*close*/, NULL /*create_directory*/, NULL /*get_vm_object*/,
NULL /*truncate*/, NULL /*stat*/, NULL /*send_signal*/, tcp_connect);
if (!inode) {
kfree(con);
return -ENOMEM;
}
int fd = vfs_create_fd(O_RDWR | (is_nonblock ? O_NONBLOCK : 0), 0,
0 /*is_tty*/, inode, NULL);
if (fd < 0) {
kfree(con);
kfree(inode);
return fd;
}
return fd;
}
int socket(int domain, int type, int protocol) {
int rc = 0;
vfs_inode_t *inode = NULL;
SOCKET *new_socket = NULL;
if (!(AF_UNIX == domain || AF_INET == domain)) {
rc = -EINVAL;
goto socket_error;
}
new_socket = kmalloc(sizeof(SOCKET));
if (!new_socket) {
rc = -ENOMEM;
goto socket_error;
}
new_socket->domain = domain;
new_socket->type = type;
new_socket->protocol = protocol;
new_socket->path = NULL;
new_socket->incoming_fd = NULL;
if (AF_UNIX == domain) {
vfs_inode_t *inode = vfs_create_inode(
0 /*inode_num*/, FS_TYPE_UNIX_SOCKET, bind_has_data, socket_can_write,
1 /*is_open*/, new_socket /*internal_object*/, 0 /*file_size*/,
NULL /*open*/, NULL /*create_file*/, socket_read, socket_write,
socket_close, NULL /*create_directory*/, NULL /*get_vm_object*/,
NULL /*truncate*/, NULL /*stat*/, NULL /*send_signal*/,
NULL /*connect*/);
if (!inode) {
rc = -ENOMEM;
goto socket_error;
}
vfs_fd_t *fd;
int n = vfs_create_fd(O_RDWR | O_NONBLOCK, 0, 0 /*is_tty*/, inode, &fd);
if (n < 0) {
rc = n;
goto socket_error;
}
new_socket->fifo_file = create_fifo_object();
new_socket->ptr_socket_fd = fd;
return n;
}
if (AF_INET == domain) {
int is_udp = (SOCK_DGRAM & type);
int is_nonblock = (SOCK_NONBLOCK & type);
if (!is_udp) {
return tcp_create_fd(is_nonblock);
}
vfs_inode_t *inode = vfs_create_inode(
0 /*inode_num*/, FS_TYPE_UNIX_SOCKET, NULL, always_can_write, 1,
new_socket, 0 /*file_size*/, NULL /*open*/, NULL /*create_file*/, NULL,
NULL, NULL /*close*/, NULL /*create_directory*/, NULL /*get_vm_object*/,
NULL /*truncate*/, NULL /*stat*/, NULL /*send_signal*/, udp_connect);
if (!inode) {
rc = -ENOMEM;
goto socket_error;
}
int n = vfs_create_fd(O_RDWR | (is_nonblock ? O_NONBLOCK : 0), 0,
0 /*is_tty*/, inode, NULL);
if (n < 0) {
rc = n;
goto socket_error;
}
return n;
}
ASSERT_NOT_REACHED;
socket_error:
kfree(inode);
kfree(new_socket);
return rc;
}
|