50 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
53 #include <linux/types.h>
54 #include <linux/socket.h>
163 __u32 ctsn, max_tsn_seen;
171 asoc->
peer.sack_needed = 1;
173 ctsn = sctp_tsnmap_get_ctsn(&asoc->
peer.tsn_map);
174 max_tsn_seen = sctp_tsnmap_get_max_tsn_seen(&asoc->
peer.tsn_map);
186 if (max_tsn_seen != ctsn)
187 asoc->
peer.sack_needed = 1;
197 if (!asoc->
peer.sack_needed) {
198 asoc->
peer.sack_cnt++;
208 asoc->
peer.sack_needed = 1;
215 asoc->
peer.sack_needed = 1;
230 asoc->
peer.sack_needed = 0;
231 asoc->
peer.sack_cnt = 0;
318 SCTP_ST_TIMEOUT(timeout_type),
330 static void sctp_generate_t1_cookie_event(
unsigned long data)
336 static void sctp_generate_t1_init_event(
unsigned long data)
342 static void sctp_generate_t2_shutdown_event(
unsigned long data)
348 static void sctp_generate_t4_rto_event(
unsigned long data)
354 static void sctp_generate_t5_shutdown_guard_event(
unsigned long data)
357 sctp_generate_timeout_event(asoc,
362 static void sctp_generate_autoclose_event(
unsigned long data)
376 struct net *net = sock_net(asoc->
base.sk);
414 struct net *net = sock_net(asoc->
base.sk);
444 static void sctp_generate_sack_event(
unsigned long data)
452 sctp_generate_t1_cookie_event,
453 sctp_generate_t1_init_event,
454 sctp_generate_t2_shutdown_event,
456 sctp_generate_t4_rto_event,
457 sctp_generate_t5_shutdown_guard_event,
459 sctp_generate_sack_event,
460 sctp_generate_autoclose_event,
479 static void sctp_do_8_2_transport_strike(
sctp_cmd_seq_t *commands,
498 }
else if (transport->
hb_sent) {
519 sctp_cmd_hb_timer_update(commands, transport);
525 " transport IP: port:%d failed.\n",
543 if (!is_hb || transport->
hb_sent) {
544 transport->
rto =
min((transport->
rto * 2), transport->
asoc->rto_max);
561 SCTP_ULPEVENT(event));
586 (
__u16)error, 0, 0, chunk,
594 SCTP_ULPEVENT(event));
693 int was_unconfirmed = 0;
710 t->
asoc->overall_error_count = 0;
747 if (was_unconfirmed && asoc->
peer.transport_count == 1)
760 struct net *net = sock_net(asoc->
base.sk);
833 if (waitqueue_active(&asoc->
wait))
900 switch (err_hdr->
cause) {
906 switch (unk_chunk_hdr->
type) {
914 if (asoc->
peer.asconf_capable == 0)
917 asoc->
peer.asconf_capable = 0;
933 static void sctp_cmd_process_fwdtsn(
struct sctp_ulpq *ulpq,
955 &asoc->
peer.primary_addr)) {
978 asoc->
c.sinit_num_ostreams,
979 asoc->
c.sinit_max_instreams,
1014 "T1 %s Timeout adjustment"
1015 " init_err_counter: %d"
1051 struct net *net = sock_net(asoc->
base.sk);
1060 list_del_init(entry);
1077 SCTP_DEBUG_PRINTK("sctp_do_sm prefn: " \
1078 "ep %p, %s, %s, asoc %p[%s], %s\n", \
1079 ep, sctp_evttype_tbl[event_type], \
1080 (*debug_fn)(subtype), asoc, \
1081 sctp_state_tbl[state], state_fn->name)
1083 #define DEBUG_POST \
1084 SCTP_DEBUG_PRINTK("sctp_do_sm postfn: " \
1085 "asoc %p, status: %s\n", \
1086 asoc, sctp_status_tbl[status])
1088 #define DEBUG_POST_SFX \
1089 SCTP_DEBUG_PRINTK("sctp_do_sm post sfx: error %d, asoc %p[%s]\n", \
1091 sctp_state_tbl[(asoc && sctp_id2assoc(ep->base.sk, \
1092 sctp_assoc2id(asoc)))?asoc->state:SCTP_STATE_CLOSED])
1113 static printfn_t *
table[] = {
1126 status = (*state_fn->
fn)(net, ep, asoc, subtype, event_arg, &commands);
1129 error = sctp_side_effects(event_type, subtype, state,
1130 ep, asoc, event_arg, status,
1160 if (0 != (error = sctp_cmd_interpreter(event_type, subtype, state,
1169 "event_type %d, event_id %d\n",
1170 state, event_type, subtype.
chunk);
1197 state, subtype.
chunk);
1201 pr_warn(
"unimplemented feature in state %d, event_type %d, event_id %d\n",
1202 state, event_type, subtype.
chunk);
1206 pr_err(
"bug in state %d, event_type %d, event_id %d\n",
1207 state, event_type, subtype.
chunk);
1212 pr_err(
"impossible disposition %d in state %d, event_type %d, event_id %d\n",
1213 status, state, event_type, subtype.
chunk);
1227 static int sctp_cmd_interpreter(
sctp_event_t event_type,
1260 switch (cmd->verb) {
1271 asoc = cmd->obj.ptr;
1291 sctp_cmd_delete_tcb(commands, asoc);
1297 sctp_cmd_new_state(commands, asoc, cmd->obj.
state);
1303 cmd->obj.u32,
NULL);
1318 sctp_cmd_process_fwdtsn(&asoc->
ulpq, cmd->obj.ptr);
1327 force = cmd->obj.i32;
1328 error = sctp_gen_sack(asoc, force, commands);
1333 error = sctp_cmd_process_sack(commands, asoc,
1345 SCTP_CHUNK(new_obj));
1354 error = sctp_cmd_process_init(commands, asoc, chunk,
1367 SCTP_CHUNK(new_obj));
1374 SCTP_CHUNK(cmd->obj.ptr));
1393 if ((asoc->
peer.retran_path !=
1394 asoc->
peer.primary_path) &&
1414 SCTP_CHUNK(new_obj));
1420 "chunk_up:", cmd->obj.ptr,
1421 "ulpq:", &asoc->
ulpq);
1429 "event_up:",cmd->obj.ptr,
1430 "ulpq:",&asoc->
ulpq);
1446 packet = cmd->obj.ptr;
1465 sctp_do_ecn_ce_work(asoc, cmd->obj.u32);
1470 new_obj = sctp_do_ecn_ecne_work(asoc, cmd->obj.u32,
1474 SCTP_CHUNK(new_obj));
1479 sctp_do_ecn_cwr_work(asoc, cmd->obj.u32);
1483 sctp_cmd_setup_t2(commands, asoc, cmd->obj.ptr);
1487 timer = &asoc->
timers[cmd->obj.to];
1489 if (timer_pending(timer))
1494 timer = &asoc->
timers[cmd->obj.to];
1495 timeout = asoc->
timeouts[cmd->obj.to];
1504 timer = &asoc->
timers[cmd->obj.to];
1505 timeout = asoc->
timeouts[cmd->obj.to];
1506 if (!
mod_timer(timer, jiffies + timeout))
1511 timer = &asoc->
timers[cmd->obj.to];
1512 if (timer_pending(timer) &&
del_timer(timer))
1517 chunk = cmd->obj.ptr;
1534 sctp_cmd_t1_timer_update(asoc,
1549 sctp_cmd_t1_timer_update(asoc,
1568 sctp_cmd_init_failed(commands, asoc, cmd->obj.err);
1572 sctp_cmd_assoc_failed(commands, asoc, event_type,
1573 subtype, chunk, cmd->obj.err);
1590 sctp_tsnmap_mark_dup(&asoc->
peer.tsn_map,
1600 sctp_do_8_2_transport_strike(commands, asoc,
1601 cmd->obj.transport, 0);
1605 t = cmd->obj.transport;
1610 t = cmd->obj.transport;
1611 sctp_do_8_2_transport_strike(commands, asoc,
1617 t = cmd->obj.transport;
1618 sctp_cmd_transport_on(commands, asoc, t, chunk);
1622 sctp_cmd_hb_timers_start(commands, asoc);
1626 t = cmd->obj.transport;
1627 sctp_cmd_hb_timer_update(commands, t);
1631 sctp_cmd_hb_timers_stop(commands, asoc);
1635 error = cmd->obj.error;
1640 sackh.cum_tsn_ack = cmd->obj.be32;
1641 sackh.a_rwnd = asoc->
peer.rwnd +
1643 sackh.num_gap_ack_blocks = 0;
1644 sackh.num_dup_tsns = 0;
1663 t = cmd->obj.transport;
1678 sctp_cmd_setup_t4(commands, asoc, cmd->obj.ptr);
1682 sctp_cmd_process_operr(commands, asoc, chunk);
1685 asoc->
peer.i.init_tag = 0;
1688 sctp_cmd_del_non_primary(asoc);
1691 sctp_cmd_t3_rtx_timers_stop(commands, asoc);
1694 t = asoc->
peer.retran_path;
1695 asoc->
peer.retran_path = asoc->
peer.primary_path;
1698 asoc->
peer.retran_path =
t;
1701 sctp_cmd_set_sk_err(asoc, cmd->obj.error);
1704 sctp_cmd_assoc_change(commands, asoc,
1708 sctp_cmd_adaptation_ind(commands, asoc);
1716 asoc->
peer.i.init_tag = cmd->obj.u32;
1723 error = sctp_cmd_send_msg(asoc, cmd->obj.msg);
1726 sctp_cmd_send_asconf(asoc);
1733 asoc = cmd->obj.asoc;
1737 pr_warn(
"Impossible command: %u, %p\n",
1738 cmd->verb, cmd->obj.ptr);
1754 }
else if (local_cork)