607 #include <sys/epoll.h> 609 #include <sys/types.h> 611 #include <sys/socket.h> 612 #include <netinet/in.h> 613 #include <netinet/ip.h> 614 #include <arpa/inet.h> 618 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_NET 640 #include "net/sock/xcode_xc.h" 644 #ifdef ENABLE_SOCK_MOCK_LNET 645 #define MOCK_LNET (1) 647 #define MOCK_LNET (0) 941 const struct sock *
s);
976 #define SAFE(val, exp, fallback) ((val) != NULL ? (exp) : (fallback)) 979 #define EP_P(e) SAFE(e, (e)->e_ep.nep_addr, "null") 980 #define EP_FL EP_F "->" EP_F 981 #define EP_PL(e) EP_P(SAFE(e, ma_src(ep_ma(e)), NULL)), EP_P(e) 983 #define SOCK_F EP_FL "/%i/%" PRIx64 "/%i" 984 #define SOCK_P(s) EP_PL(SAFE(s, (s)->s_ep, NULL)), \ 985 SAFE(s, (s)->s_sm.sm_state, 0), \ 986 SAFE(s, (s)->s_flags, 0), SAFE(s, (s)->s_fd, 0) 988 #define B_F "[[%i]@%p:"EP_FL"]" 989 #define B_P(b) (b)->b_buf->nb_qtype, (b), EP_PL((b)->b_other) 991 #define TLOG(...) do { ; } while (0) 994 static,
struct sock, s_linkage, s_magix,
999 static,
struct mover, m_linkage, m_magix,
1004 static,
struct buf, b_linkage, b_magix,
1142 static void ip4_encode(
const struct addr *a,
struct sockaddr *sa);
1143 static void ip4_decode(
struct addr *a,
const struct sockaddr *sa);
1144 static void ip6_encode(
const struct addr *a,
struct sockaddr *sa);
1145 static void ip6_decode(
struct addr *a,
const struct sockaddr *sa);
1183 .st_proto = IPPROTO_TCP
1190 .st_proto = IPPROTO_UDP
1207 #define EP_GET(e, f) \ 1208 ({ struct ep *__ep = (e); ep_get(__ep); M0_CNT_INC(__ep->e_r_ ## f); }) 1209 #define EP_PUT(e, f) \ 1210 ({ struct ep *__ep = (e); ep_put(__ep); M0_CNT_DEC(__ep->e_r_ ## f); }) 1212 #define EP_GET(e, f) ep_get(e) 1213 #define EP_PUT(e, f) ep_put(e) 1219 const struct m0_tl *eps = &
net->ntm_end_points;
1222 _0C(
net->ntm_xprt_private ==
ma) &&
1227 m0_nep_tlist_is_empty(eps) &&
1257 s_tlist_contains(&
s->s_ep->e_sock,
s));
1291 (
void *)
ma->
t_ma,
true) &&
1306 dead + (
s->s_ep ==
ep))) &&
1322 return _0C(m_tlink_is_in(
m) == (
m->m_ep !=
NULL)) &&
1325 stype[
i].st_reader ==
m->m_op));
1362 enum { EV_NR = 256 };
1363 struct epoll_event ev[EV_NR] = {};
1397 for (
i = 0;
i <
nr; ++
i) {
1398 struct sock *
s = ev[
i].data.ptr;
1456 net->ntm_xprt_private =
ma;
1462 result =
M0_ERR(-ENOMEM);
1463 return M0_RC(result);
1532 struct ma *
ma =
net->ntm_xprt_private;
1553 struct ma *
ma =
net->ntm_xprt_private;
1591 return M0_RC(result);
1605 struct ma *
ma =
net->ntm_xprt_private;
1645 .nte_next_state = state,
1707 struct buf *b = nb->nb_xprt_private;
1709 b->b_done.b_words == NULL &&
1710 m0_vec_count(&nb->nb_buffer.ov_vec) >= len;
1733 struct ma *
ma =
net->ntm_xprt_private;
1739 return M0_RC(result);
1843 return M0_RC(result);
1939 return sizeof(
struct bdesc);
1981 (w = m_tlist_head(&
s->s_ep->e_writer)) !=
NULL) {
1984 m_tlist_move_tail(&
s->s_ep->e_writer, w);
2001 struct mover *w = m_tlist_head(&
s->s_ep->e_writer);
2026 s_tlink_del_fini(
s);
2053 int result =
sock_ctl(
s, EPOLL_CTL_DEL, 0);
2055 shutdown(
s->s_fd, SHUT_RDWR);
2092 src->e_a.a_family ==
tgt->e_a.a_family &&
2093 src->e_a.a_socktype ==
tgt->e_a.a_socktype &&
2094 src->e_a.a_protocol ==
tgt->e_a.a_protocol));
2103 s->s_reader.m_sock =
s;
2111 result = listen(
s->s_fd, 128);
2122 struct sockaddr_storage sa = {};
2125 result = connect(
s->s_fd,
2126 (
void *)&sa,
sizeof sa);
2130 }
else if (errno == EINPROGRESS) {
2146 return M0_RC(result);
2170 if (
flags & EPOLLET) {
2171 struct sockaddr_storage sa = {};
2173 result = setsockopt(
fd, SOL_SOCKET,
2178 result = bind(
fd, (
void *)&sa,
2186 if (
fd >= 0 && result == 0) {
2190 if (result != 0 ||
fd < 0)
2192 return M0_RC(result);
2203 enum { EV_ERR = EPOLLRDHUP|EPOLLERR|EPOLLHUP };
2204 struct sockaddr_storage sa = {};
2211 switch (
s->s_sm.sm_state) {
2218 if (ev == EPOLLIN) {
2220 socklen_t socklen =
sizeof sa;
2221 struct ep *we =
s->s_ep;
2224 fd = accept4(
s->s_fd,
2225 (
void *)&sa, &socklen, SOCK_NONBLOCK);
2248 }
else if (M0_IN(errno, (EWOULDBLOCK,
2260 (ENETDOWN, EPROTO, ENOPROTOOPT,
2262 EHOSTUNREACH, EOPNOTSUPP,
2270 "Unexpected event while listening: %x.", ev);
2273 if ((ev & (EPOLLOUT|EPOLLIN)) == EPOLLOUT) {
2276 }
else if ((ev & (EPOLLOUT|EPOLLIN)) == (EPOLLOUT|EPOLLIN)) {
2281 "Unexpected event while connecting: %x.", ev);
2290 if (
s->s_sm.sm_state ==
S_OPEN && ev & EPOLLOUT)
2292 if (
s->s_sm.sm_state ==
S_OPEN && ev & EV_ERR)
2296 if (ev & ~(EPOLLIN|EPOLLOUT|EV_ERR))
2310 flags |= EPOLLIN | EPOLLRDHUP | EPOLLERR | EPOLLHUP;
2312 &(
struct epoll_event){
2314 .data = { .ptr = s }});
2316 if ((
flags & EPOLLOUT) != 0)
2369 net->nep_addr = cname;
2440 if (m_tlink_is_in(w)) {
2484 result =
sock_ctl(
s, EPOLL_CTL_MOD, EPOLLOUT);
2495 m0_nep_tlist_del(&
ep->
e_ep);
2530 return M0_RC(result);
2559 result =
M0_ERR(-EPROTO);
2560 else if (
name[0] <
'0' ||
name[0] >
'9')
2566 return M0_RC(result);
2582 struct sockaddr_in sin;
2583 char *
at = strchr(
name,
'@');
2584 char ip[INET_ADDRSTRLEN] = {};
2590 if (strncmp(
name,
"0@lo", 4) == 0) {
2591 sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
2596 if (inet_pton(AF_INET, ip, &sin.sin_addr) != 1)
2599 sin.sin_family = AF_INET;
2600 if ((
at = strchr(
at,
':')) ==
NULL)
2602 nr = sscanf(
at + 1,
"%u:%u:%u", &pid, &portal, &tmid);
2604 nr = sscanf(
at + 1,
"%u:%u:*", &pid, &portal);
2614 return M0_ERR(-EADDRNOTAVAIL);
2631 if (tmid >= 1024 || (portal - 30) >= 32)
2633 "portal: %u, tmid: %u", portal, tmid);
2634 sin.sin_port = htons(tmid | (1 << 10) | ((portal - 30) << 11));
2652 char ip[INET6_ADDRSTRLEN] = {};
2656 shift = strlen(
pf[
f].f_name);
2657 if (strncmp(
name,
pf[
f].f_name, shift) == 0)
2666 shift = strlen(
stype[
s].st_name);
2667 if (strncmp(
name,
stype[
s].st_name, shift) == 0)
2679 port = strtol(
at + 1, &end, 10);
2684 if (port < 0 || port > USHRT_MAX)
2704 struct sockaddr_in *sin = (
void *)sa;
2708 sin->sin_len =
sizeof *sin;
2710 sin->sin_port = htons(a->
a_port);
2711 sin->sin_addr.s_addr = *(uint32_t *)&a->
a_data.
v_data[0];
2717 const struct sockaddr_in *sin = (
void *)sa;
2719 a->
a_port = ntohs(sin->sin_port);
2720 *((uint32_t *)&a->
a_data.
v_data[0]) = sin->sin_addr.s_addr;
2726 struct sockaddr_in6 *sin6 = (
void *)sa;
2730 sin6->sin6_len =
sizeof *sin6;
2732 sin6->sin6_port = htons(a->
a_port);
2734 sizeof sin6->sin6_addr.s6_addr);
2740 struct sockaddr_in6 *sin6 = (
void *)sa;
2742 a->
a_port = ntohs(sin6->sin6_port);
2744 sizeof sin6->sin6_addr.s6_addr);
2752 struct sockaddr_storage sa = {};
2754 enum {
MAX_LEN =
sizeof(
"inet6:stream:@65536") + INET6_ADDRSTRLEN };
2766 struct sockaddr_in *sin = (
void *)&sa;
2768 inet_ntop(AF_INET, &sin->sin_addr,
name + nob,
MAX_LEN - nob);
2772 struct sockaddr_in6 *sin = (
void *)&sa;
2774 inet_ntop(AF_INET6, &sin->sin6_addr,
name + nob,
MAX_LEN - nob);
2844 if (
p->p_offset +
p->p_size > length)
2845 return M0_ERR(-EMSGSIZE);
2846 if (
p->p_totalsize > length)
2847 return M0_ERR(-EMSGSIZE);
2864 result =
M0_ERR(-EPROTO);
2866 result =
M0_ERR(-EPROTO);
2868 result =
M0_ERR(-EPROTO);
2870 result =
M0_ERR(-EPROTO);
2872 result =
M0_ERR(-EPROTO);
2914 if (!b_tlink_is_in(
buf)) {
2985 (
void **)&
out->nbd_data, &len);
2990 return M0_RC(result);
3012 if (
m->m_sm.sm_conf !=
NULL) {
3014 if (
m->m_sm.sm_state !=
R_DONE)
3017 if (m_tlink_is_in(
m)) {
3025 m->m_sm.sm_conf =
NULL;
3058 int state =
m->m_sm.sm_state;
3070 while (
s->s_flags &
M0_BITS(
op) || !
m->m_op->v_op[state][
op].o_doesio) {
3072 m->m_op->v_name, state,
op);
3074 if (
m->m_op->v_done !=
NULL)
3075 m->m_op->v_done(
m,
s);
3079 }
else if (
s->s_sm.sm_state !=
S_OPEN) {
3081 }
else if (
m->m_op->v_op[state][
op].o_op ==
NULL) {
3086 state =
m->m_op->v_op[state][
op].o_op(
m,
s);
3097 if (state == -ENOBUFS)
3100 if (
m->m_op->v_error !=
NULL)
3101 m->m_op->v_error(
m,
s, state);
3105 state =
m->m_sm.sm_state;
3134 return sizeof m->m_pkbuf +
m->m_pk.p_size;
3142 return max64(
m->m_nob -
sizeof m->m_pkbuf, 0);
3155 if (nob < sizeof m->m_pkbuf)
3187 if (
m->m_nob <
sizeof m->m_pkbuf) {
3189 iv[0].iov_base = &
m->m_pkbuf[
m->m_nob];
3190 *
count = iv[0].iov_len =
sizeof m->m_pkbuf -
m->m_nob;
3196 if (
tgt ==
sizeof m->m_pkbuf)
3207 *
count += (iv[idx].iov_len = frag);
3225 struct iovec iv[256] = {};
3232 bv ?:
m->m_buf !=
NULL ?
3234 s->s_flags &= ~
flag;
3245 }
else if (errno == EWOULDBLOCK) {
3247 }
else if (errno == EINTR) {
3269 p->p_dst =
m->m_buf->b_peer;
3270 p->p_totalsize =
m->m_buf->b_buf->nb_length;
3306 if (
p->p_idx >=
p->p_nr)
3308 if (
p->p_offset +
p->p_size <
p->p_offset)
3310 if (
p->p_offset +
p->p_size >
p->p_totalsize)
3312 if (
p->p_idx == 0 &&
p->p_offset != 0)
3314 if (
p->p_idx ==
p->p_nr - 1 &&
3315 p->p_offset +
p->p_size !=
p->p_totalsize)
3319 if (!
addr_eq(&
m->m_sock->s_ep->e_a, &
p->p_src.bd_addr))
3321 hassrc = !
M0_IS0(&
p->p_src.bd_cookie);
3322 hasdst = !
M0_IS0(&
p->p_dst.bd_cookie);
3323 if (!hassrc && !hasdst)
3330 p->p_dst.bd_cookie.co_addr,
3331 p->p_dst.bd_cookie.co_generation);
3336 memcmp(&
buf->
b_peer, &
p->p_src,
sizeof p->p_src) != 0)
3340 if (
p->p_idx != 0 ||
p->p_nr != 1 ||
p->p_size != 0 ||
3341 p->p_offset != 0 || !hasdst)
3423 void *
buf =
m->m_pkbuf;
3472 else if (self->m_nob <
sizeof self->m_pkbuf)
3475 M0_ASSERT(self->m_nob ==
sizeof self->m_pkbuf);
3488 return result >= 0 ?
pk_state(
self) : result;
3512 if (
m->m_sock !=
NULL) {
3535 if (self->m_scratch ==
NULL) {
3537 if (self->m_scratch ==
NULL)
3559 sizeof self->m_pkbuf + maxsize);
3562 if (self->m_nob <
sizeof self->m_pkbuf)
3567 dsize =
self->m_pk.p_size;
3568 if (self->m_nob !=
sizeof self->m_pkbuf + dsize)
3569 return M0_ERR(-EMSGSIZE);
3603 - (
s->s_ep->e_a.a_family == AF_INET ? 20 : 40)
3649 return result >= 0 ?
pk_state(w) : result;
3722 .sd_name =
"listening",
3726 .sd_name =
"connecting",
3730 .sd_name =
"active",
3734 .sd_name =
"deleted",
3765 .sd_name =
"datagram",
3769 .sd_name =
"header",
3774 .sd_name =
"interval",
3778 .sd_name =
"datagram-done",
3824 .
v_name =
"stream-reader",
3835 .
v_name =
"dgram-reader",
3952 result = sigaction(SIGPIPE,
3953 &(
struct sigaction){ .sa_handler = SIG_IGN },
NULL);
3954 return result != 0 ?
M0_ERR(-errno) : 0;
3967 printf(
"\t%p: %s sock: %p state: %i buf: %p\n",
m,
3969 m->m_sock,
m->m_sm.sm_state,
m->m_buf);
3975 printf(
"\t%s\n",
s);
3981 printf(
"\t\tfd: %i, flags: %" PRIx64 ", state: %i\n",
3990 printf(
"NULL ep\n");
3992 printf(
"\t%p: ",
ep);
4026 printf(
"\t ---%i[]---\n",
i);
4032 #undef M0_TRACE_SUBSYSTEM
static void buf_complete(struct buf *buf)
#define M0_BUFVEC_INIT_BUF(addr_ptr, count_ptr)
M0_INTERNAL int m0_xcode_encdec(struct m0_xcode_obj *obj, struct m0_bufvec_cursor *cur, enum m0_xcode_what what)
struct m0_tlink m_linkage
M0_INTERNAL int m0_mutex_trylock(struct m0_mutex *mutex)
static void stream_error(struct mover *m, struct sock *s)
static int dgram_header(struct mover *self, struct sock *s)
static void ma_fini(struct m0_net_transfer_mc *ma)
static struct m0_addb2_philter p
static void ip6_decode(struct addr *a, const struct sockaddr *sa)
static bool buf_invariant(const struct buf *buf)
static struct buf * ma_recv_buf(struct ma *ma, m0_bcount_t len)
struct m0_net_transfer_mc * nb_tm
M0_INTERNAL int m0_bitmap_init(struct m0_bitmap *map, size_t nr)
static bool addr_eq(const struct addr *a0, const struct addr *a1)
M0_INTERNAL void m0_mutex_unlock(struct m0_mutex *mutex)
static m0_bcount_t get_max_buffer_segment_size(const struct m0_net_domain *)
static void sock_done(struct sock *s, bool balance)
static void ep_del(struct mover *w)
int(* o_op)(struct mover *self, struct sock *s)
struct m0_format_footer p_footer
static int writer_idle(struct mover *self, struct sock *s)
int const char const void size_t int flags
static void sock_close(struct sock *s)
static struct m0_semaphore q
static bool ma_invariant(const struct ma *ma)
static void poller(struct ma *ma)
M0_INTERNAL void m0_bitmap_fini(struct m0_bitmap *map)
static void ip4_decode(struct addr *a, const struct sockaddr *sa)
static int sock_init(int fd, struct ep *src, struct ep *tgt, uint32_t flags)
static struct m0_addb2_mach * m
static int pk_iov_prep(struct mover *m, struct iovec *iv, int nr, struct m0_bufvec *bv, m0_bcount_t size, int *count)
static struct buffer * cur(struct m0_addb2_mach *mach, m0_bcount_t space)
static const struct m0_sm_conf sock_conf
struct m0_bufvec nb_buffer
static int dgram_idle(struct mover *self, struct sock *s)
M0_INTERNAL void m0_net__tm_cancel(struct m0_net_transfer_mc *tm)
int m0_thread_join(struct m0_thread *q)
static struct ma * ep_ma(struct ep *ep)
M0_INTERNAL int m0_net_sock_mod_init(void)
static uint64_t tag(uint8_t code, uint64_t id)
static int stream_pk_done(struct mover *self, struct sock *s)
struct m0_thread t_poller
static m0_bcount_t pk_tsize(const struct mover *m)
#define M0_LOG(level,...)
M0_INTERNAL void m0_net_buffer_pool_unlock(struct m0_net_buffer_pool *pool)
static void ma_lock(struct ma *ma)
struct m0_sm_group ntm_group
static int stream_idle(struct mover *self, struct sock *s)
static void mover_init(struct mover *m, struct ma *ma, const struct mover_op_vec *vop)
static void ma__fini(struct ma *ma)
enum m0_net_tm_state ntm_state
static int ma_confine(struct m0_net_transfer_mc *ma, const struct m0_bitmap *processors)
char m_pkbuf[sizeof(struct packet)]
M0_INTERNAL void m0_net_xprt_default_set(const struct m0_net_xprt *xprt)
M0_INTERNAL bool m0_net__ep_invariant(struct m0_net_end_point *ep, struct m0_net_transfer_mc *tm, bool under_tm_mutex)
static const struct m0_format_tag get_tag
static int ep_create(struct ma *ma, struct addr *addr, const char *name, struct ep **out)
#define m0_exists(var, nr,...)
static int ep_add(struct ep *ep, struct mover *w)
static bool addr_invariant(const struct addr *addr)
M0_INTERNAL void * m0_bufvec_cursor_addr(struct m0_bufvec_cursor *cur)
struct m0_tlink s_linkage
#define M0_THREAD_INIT(thread, TYPE, init, func, arg, namefmt,...)
static void pk_decode(struct mover *m)
struct m0_tlink b_linkage
struct m0_cookie bd_cookie
struct m0_format_header p_header
#define container_of(ptr, type, member)
M0_INTERNAL void ep__print(const struct ep *ep)
M0_INTERNAL void m0_mutex_lock(struct m0_mutex *mutex)
M0_INTERNAL void m0_net_sock_mod_fini(void)
M0_INTERNAL int m0_data_to_bufvec_copy(struct m0_bufvec_cursor *cur, void *data, size_t len)
struct m0_net_buffer * nbe_buffer
static void ma_unlock(struct ma *ma)
static int pk_io(struct mover *w, struct sock *s, uint64_t flag, struct m0_bufvec *bv, m0_bcount_t size)
static int writer_pk_done(struct mover *self, struct sock *s)
static int writer_pk(struct mover *self, struct sock *s)
M0_INTERNAL void m0_net_buffer_event_post(const struct m0_net_buffer_event *ev)
static void pk_encdec(struct mover *m, enum m0_xcode_what what)
struct m0_net_end_point * nbe_ep
M0_INTERNAL uint32_t default_xo_rpc_max_segs_nr(struct m0_net_domain *ndom)
struct m0_tl ntm_end_points
static bool mover_is_writer(const struct mover *m)
static bool mover_invariant(const struct mover *m)
static int writer_write(struct mover *self, struct sock *s)
static bool sock_invariant(const struct sock *s)
static int ep_balance(struct ep *ep)
M0_INTERNAL int m0_net__tm_provision_buf(struct m0_net_transfer_mc *tm)
static m0_bcount_t stream_pk_size(const struct mover *w, const struct sock *s)
M0_INTERNAL bool m0_bufvec_cursor_move(struct m0_bufvec_cursor *cur, m0_bcount_t count)
static void buf_deregister(struct m0_net_buffer *nb)
static int pk_state(const struct mover *w)
static void ip4_encode(const struct addr *a, struct sockaddr *sa)
static void dom_fini(struct m0_net_domain *dom)
M0_INTERNAL void m0_net_xprt_register(const struct m0_net_xprt *xprt)
static int64_t max64(int64_t a, int64_t b)
M0_INTERNAL void m0_ref_put(struct m0_ref *ref)
#define M0_ERR_INFO(rc, fmt,...)
static struct ep * ep_net(struct m0_net_end_point *net)
void m0_ref_init(struct m0_ref *ref, int init_num, void(*release)(struct m0_ref *ref))
return M0_ERR(-EOPNOTSUPP)
static const struct m0_net_xprt_ops xprt_ops
static void buf_del(struct m0_net_buffer *nb)
M0_INTERNAL void m0_ref_get(struct m0_ref *ref)
static const struct m0_format_tag put_tag
static void ep_free(struct ep *ep)
static bool ma_is_locked(const struct ma *ma)
static bool sock_event(struct sock *s, uint32_t ev)
static const struct socktype stype[]
enum m0_net_queue_type nb_qtype
static struct ma * buf_ma(struct buf *buf)
M0_INTERNAL m0_bcount_t m0_bufvec_cursor_step(const struct m0_bufvec_cursor *cur)
static struct m0_sm_state_descr sock_conf_state[]
M0_INTERNAL bool m0_mutex_is_locked(const struct m0_mutex *mutex)
static int stream_header(struct mover *self, struct sock *s)
static int ma_stop(struct m0_net_transfer_mc *ma, bool cancel)
m0_time_t m0_time_now(void)
void m0_sm_state_set(struct m0_sm *mach, int state)
#define M0_DEFAULT_NETWORK
static int addr_parse_lnet(struct addr *addr, const char *name)
static void addr_encode(const struct addr *addr, struct sockaddr *sa)
static int end_point_create(struct m0_net_end_point **epp, struct m0_net_transfer_mc *ma, const char *name)
M0_INTERNAL void mover__print(const struct mover *m)
static const struct pfamily pf[]
static const struct m0_sm_conf rw_conf
static void pk_encode(struct mover *m)
void(* f_decode)(struct addr *a, const struct sockaddr *sa)
void m0_thread_fini(struct m0_thread *q)
static int buf_add(struct m0_net_buffer *nb)
static struct m0_stob_domain * dom
struct m0_net_buffer * b_buf
const struct m0_net_xprt m0_net_sock_xprt
M0_INTERNAL void m0_bufvec_cursor_init(struct m0_bufvec_cursor *cur, const struct m0_bufvec *bvec)
M0_INTERNAL int m0_xcode_obj_enc_to_buf(struct m0_xcode_obj *obj, void **buf, m0_bcount_t *len)
static bool ep_invariant(const struct ep *ep)
M0_INTERNAL int m0_bitmap_ffz(const struct m0_bitmap *map)
uint32_t ntm_callback_counter
M0_INTERNAL m0_bcount_t default_xo_rpc_max_seg_size(struct m0_net_domain *ndom)
static void mover_fini(struct mover *m)
void(* v_done)(struct mover *self, struct sock *s)
static int addr_parse_native(struct addr *addr, const char *name)
static struct mover * sock_writer(struct sock *s)
void * m0_alloc(size_t size)
M0_INTERNAL void m0_net_tm_event_post(const struct m0_net_tm_event *ev)
static m0_bcount_t get_max_buffer_size(const struct m0_net_domain *dom)
static void get_done(struct mover *w, struct sock *s)
static int buf_register(struct m0_net_buffer *nb)
static void sock_fini(struct sock *s)
m0_bcount_t(* st_pk_size)(const struct mover *w, const struct sock *s)
const struct mover_op_vec * st_reader
static int sock_in(struct sock *s)
static void bev_deliver_all(struct m0_net_transfer_mc *ma)
M0_INTERNAL void m0_cookie_init(struct m0_cookie *cookie, const uint64_t *obj)
M0_INTERNAL void m0_bitmap_set(struct m0_bitmap *map, size_t idx, bool val)
static int ma_start(struct m0_net_transfer_mc *ma, const char *name)
static m0_bcount_t pk_dnob(const struct mover *m)
const struct m0_net_xprt m0_net_lnet_xprt
struct m0_net_transfer_mc * nep_tm
static void ma_buf_done(struct ma *ma)
static void ep_get(struct ep *ep)
static uint64_t min64u(uint64_t a, uint64_t b)
static int addr_resolve(struct addr *addr, const char *name)
static int bev_deliver_sync(struct m0_net_transfer_mc *ma)
struct m0_tl ntm_q[M0_NET_QT_NR]
static void buf_done(struct buf *buf, int rc)
M0_INTERNAL m0_bcount_t m0_vec_count(const struct m0_vec *vec)
static void sock_out(struct sock *s)
static char * addr_print(const struct addr *addr)
static void ma_buf_timeout(struct ma *ma)
static int sock_init_fd(int fd, struct sock *s, struct ep *ep, uint32_t flags)
static struct m0_pool pool
static void writer_done(struct mover *self, struct sock *s)
#define m0_forall(var, nr,...)
static m0_bcount_t dgram_pk_size(const struct mover *w, const struct sock *s)
static void bev_notify(struct m0_net_transfer_mc *ma, struct m0_chan *chan)
static bool at(struct ff2c_context *ctx, char c)
void(* v_error)(struct mover *self, struct sock *s, int rc)
struct m0_pdclust_tgt_addr tgt
static int dgram_interval(struct mover *self, struct sock *s)
static int get_idle(struct mover *self, struct sock *s)
static int ma_init(struct m0_net_transfer_mc *ma)
static void ep_put(struct ep *ep)
static const struct mover_op_vec dgram_reader_op
M0_INTERNAL bool m0_net__buffer_invariant(const struct m0_net_buffer *buf)
static struct m0_chan chan[RDWR_REQUEST_MAX]
struct m0_net_end_point * ntm_ep
static void ep_release(struct m0_ref *ref)
M0_INTERNAL void m0_sm_init(struct m0_sm *mach, const struct m0_sm_conf *conf, uint32_t state, struct m0_sm_group *grp)
static int dom_init(const struct m0_net_xprt *xprt, struct m0_net_domain *dom)
#define M0_ALLOC_PTR(ptr)
M0_INTERNAL bool m0_net__tm_invariant(const struct m0_net_transfer_mc *tm)
static int64_t min64(int64_t a, int64_t b)
M0_INTERNAL int m0_xcode_obj_dec_from_buf(struct m0_xcode_obj *obj, void *buf, m0_bcount_t len)
M0_INTERNAL struct m0_thread * m0_thread_self(void)
static m0_bcount_t pk_size(const struct mover *m, const struct sock *s)
M0_INTERNAL void ma__print(const struct ma *ma)
static int bdesc_decode(const struct m0_net_buf_desc *nbd, struct bdesc *out)
static m0_bcount_t get_max_buffer_desc_size(const struct m0_net_domain *)
struct mover_op v_op[STATE_NR][M_NR]
M0_INTERNAL void m0_cookie_new(uint64_t *gen)
M0_INTERNAL bool m0_bitmap_get(const struct m0_bitmap *map, size_t idx)
static int get_pk(struct mover *self, struct sock *s)
M0_INTERNAL void addr__print(const struct addr *addr)
M0_TL_DESCR_DEFINE(s, "sockets", static, struct sock, s_linkage, s_magix, M0_NET_SOCK_SOCK_MAGIC, M0_NET_SOCK_SOCK_HEAD_MAGIC)
static struct m0_sm_trans_descr rw_conf_trans[]
static struct ep * ma_src(struct ma *ma)
#define IS_IN_ARRAY(idx, array)
static void ma_event_post(struct ma *ma, enum m0_net_tm_state state)
static int addr_parse(struct addr *addr, const char *name)
static struct m0_sm_trans_descr sock_conf_trans[]
struct m0t1fs_filedata * fd
static bool mover_is_reader(const struct mover *m)
M0_INTERNAL void m0_net_xprt_deregister(const struct m0_net_xprt *xprt)
static int sock_ctl(struct sock *s, int op, uint32_t flags)
int(* xo_dom_init)(const struct m0_net_xprt *xprt, struct m0_net_domain *dom)
#define M0_XCODE_OBJ(type, ptr)
static uint32_t get_rpc_max_segs_nr(struct m0_net_domain *ndom)
static struct m0_addb2_net * net
static bool bev_pending(struct m0_net_transfer_mc *ma)
struct m0_net_buf_desc nb_desc
static bool ep_eq(const struct ep *ep, const struct addr *addr)
static int ep_find(struct ma *ma, const char *name, struct ep **out)
static m0_bcount_t get_rpc_max_seg_size(struct m0_net_domain *ndom)
static int mover_op(struct mover *m, struct sock *s, int op)
static void buf_fini(struct buf *buf)
static void writer_error(struct mover *w, struct sock *s, int rc)
static const struct mover_op_vec writer_op
struct m0_net_xprt * xprt
static int pk_header_done(struct mover *m)
void(* st_error)(struct mover *m, struct sock *s)
M0_INTERNAL void buf__print(const struct buf *buf)
static void ma_prune(struct ma *ma)
static const struct mover_op_vec get_op
static void dgram_error(struct mover *m, struct sock *s)
static int stream_interval(struct mover *self, struct sock *s)
static void pk_done(struct mover *m)
#define m0_tl_find(name, var, head,...)
M0_INTERNAL void sock__print(const struct sock *sock)
static int bdesc_encode(const struct bdesc *bd, struct m0_net_buf_desc *out)
struct m0_net_transfer_mc * t_ma
#define m0_tl_for(name, head, obj)
M0_INTERNAL uint32_t default_xo_rpc_max_recv_msgs(struct m0_net_domain *ndom, m0_bcount_t rpc_size)
static int buf_accept(struct buf *buf, struct mover *m)
static struct m0_addb2_source * s
static const struct mover_op_vec stream_reader_op
static struct m0_sm_state_descr rw_conf_state[]
static int stream_pk(struct mover *self, struct sock *s)
static int32_t get_max_buffer_segments(const struct m0_net_domain *dom)
M0_INTERNAL m0_bcount_t default_xo_rpc_max_msg_size(struct m0_net_domain *ndom, m0_bcount_t rpc_size)
struct m0_pdclust_src_addr src
M0_INTERNAL void m0_chan_broadcast(struct m0_chan *chan)
#define offsetof(typ, memb)
const struct m0_sm_conf * sm_conf
M0_TL_DEFINE(s, static, struct sock)
#define m0_tl_exists(name, var, head,...)
static int bdesc_create(struct addr *addr, struct buf *buf, struct m0_net_buf_desc *out)
static void ip6_encode(const struct addr *a, struct sockaddr *sa)
struct m0_net_end_point e_ep
static void pk_header_init(struct mover *m, struct sock *s)
const struct mover_op_vec * m_op
static int dgram_pk(struct mover *self, struct sock *s)
struct m0_net_end_point * nb_ep
#define m0_tl_forall(name, var, head,...)
static void addr_decode(struct addr *addr, const struct sockaddr *sa)
void(* f_encode)(const struct addr *a, struct sockaddr *sa)
#define M0_IMPOSSIBLE(fmt,...)
static int dgram_pk_done(struct mover *self, struct sock *s)
M0_INTERNAL void m0_sm_fini(struct m0_sm *mach)
M0_INTERNAL int m0_cookie_dereference(const struct m0_cookie *cookie, uint64_t **addr)
struct m0_net_buffer_pool * ntm_recv_pool