aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vnet/sctp/sctp.api8
-rw-r--r--src/vnet/sctp/sctp.c70
-rw-r--r--src/vnet/sctp/sctp.h8
-rw-r--r--src/vnet/sctp/sctp_api.c22
4 files changed, 106 insertions, 2 deletions
diff --git a/src/vnet/sctp/sctp.api b/src/vnet/sctp/sctp.api
index f2c48d664f8..6253c954d1c 100644
--- a/src/vnet/sctp/sctp.api
+++ b/src/vnet/sctp/sctp.api
@@ -34,3 +34,11 @@ autoreply define sctp_add_src_dst_connection {
u8 dst_address[16];
};
+autoreply define sctp_del_src_dst_connection {
+ u32 client_index;
+ u32 context;
+ u8 is_ipv6;
+ u32 vrf_id;
+ u8 src_address[16];
+ u8 dst_address[16];
+ }; \ No newline at end of file
diff --git a/src/vnet/sctp/sctp.c b/src/vnet/sctp/sctp.c
index b1186a62052..cc70f7ccd8d 100644
--- a/src/vnet/sctp/sctp.c
+++ b/src/vnet/sctp/sctp.c
@@ -306,6 +306,40 @@ sctp_sub_connection_add_ip4 (vlib_main_t * vm,
}
u8
+sctp_sub_connection_del_ip4 (ip4_address_t * lcl_addr,
+ ip4_address_t * rmt_addr)
+{
+ sctp_main_t *sctp_main = vnet_get_sctp_main ();
+
+ u32 thread_idx = vlib_get_thread_index ();
+ u8 i;
+
+ ASSERT (thread_idx == 0);
+
+ for (i = 0; i < MAX_SCTP_CONNECTIONS; i++)
+ {
+ sctp_connection_t *sctp_conn = sctp_main->connections[thread_idx];
+ sctp_sub_connection_t *sub_conn =
+ &sctp_main->connections[thread_idx]->sub_conn[i];
+ ip46_address_t *lcl_ip =
+ &sctp_main->connections[thread_idx]->sub_conn[i].connection.lcl_ip;
+ ip46_address_t *rmt_ip =
+ &sctp_main->connections[thread_idx]->sub_conn[i].connection.rmt_ip;
+
+ if (!sub_conn->connection.is_ip4)
+ continue;
+ if (lcl_ip->ip4.as_u32 == lcl_addr->as_u32 &&
+ rmt_ip->ip4.as_u32 == rmt_addr->as_u32)
+ {
+ sub_conn->state = SCTP_SUBCONN_STATE_DOWN;
+ sctp_conn->forming_association_changed = 1;
+ break;
+ }
+ }
+ return SCTP_ERROR_NONE;
+}
+
+u8
sctp_sub_connection_add_ip6 (vlib_main_t * vm,
ip6_address_t * lcl_addr,
ip6_address_t * rmt_addr)
@@ -328,6 +362,42 @@ sctp_sub_connection_add_ip6 (vlib_main_t * vm,
return SCTP_ERROR_NONE;
}
+u8
+sctp_sub_connection_del_ip6 (ip6_address_t * lcl_addr,
+ ip6_address_t * rmt_addr)
+{
+ sctp_main_t *sctp_main = vnet_get_sctp_main ();
+
+ u32 thread_idx = vlib_get_thread_index ();
+ u8 i;
+
+ ASSERT (thread_idx == 0);
+
+ for (i = 0; i < MAX_SCTP_CONNECTIONS; i++)
+ {
+ sctp_connection_t *sctp_conn = sctp_main->connections[thread_idx];
+ sctp_sub_connection_t *sub_conn =
+ &sctp_main->connections[thread_idx]->sub_conn[i];
+ ip46_address_t *lcl_ip =
+ &sctp_main->connections[thread_idx]->sub_conn[i].connection.lcl_ip;
+ ip46_address_t *rmt_ip =
+ &sctp_main->connections[thread_idx]->sub_conn[i].connection.rmt_ip;
+
+ if (!sub_conn->connection.is_ip4)
+ continue;
+ if ((lcl_ip->ip6.as_u64[0] == lcl_addr->as_u64[0]
+ && lcl_ip->ip6.as_u64[1] == lcl_addr->as_u64[1])
+ && (rmt_ip->ip6.as_u64[0] == rmt_addr->as_u64[0]
+ && rmt_ip->ip6.as_u64[1] == rmt_addr->as_u64[1]))
+ {
+ sub_conn->state = SCTP_SUBCONN_STATE_DOWN;
+ sctp_conn->forming_association_changed = 1;
+ break;
+ }
+ }
+ return SCTP_ERROR_NONE;
+}
+
sctp_connection_t *
sctp_connection_new (u8 thread_index)
{
diff --git a/src/vnet/sctp/sctp.h b/src/vnet/sctp/sctp.h
index 487ff9e4824..9f17e5337ba 100644
--- a/src/vnet/sctp/sctp.h
+++ b/src/vnet/sctp/sctp.h
@@ -254,6 +254,14 @@ sctp_sub_connection_add_ip6 (vlib_main_t * vm,
ip6_address_t * lcl_addr,
ip6_address_t * rmt_addr);
+u8
+sctp_sub_connection_del_ip4 (ip4_address_t * lcl_addr,
+ ip4_address_t * rmt_addr);
+
+u8
+sctp_sub_connection_del_ip6 (ip6_address_t * lcl_addr,
+ ip6_address_t * rmt_addr);
+
void sctp_connection_close (sctp_connection_t * sctp_conn);
void sctp_connection_cleanup (sctp_connection_t * sctp_conn);
void sctp_connection_del (sctp_connection_t * sctp_conn);
diff --git a/src/vnet/sctp/sctp_api.c b/src/vnet/sctp/sctp_api.c
index 2c1b072228f..6aac77d2826 100644
--- a/src/vnet/sctp/sctp_api.c
+++ b/src/vnet/sctp/sctp_api.c
@@ -40,8 +40,9 @@
#include <vlibapi/api_helper_macros.h>
-#define foreach_sctp_api_msg \
-_(SCTP_ADD_SRC_DST_CONNECTION, sctp_add_src_dst_connection)
+#define foreach_sctp_api_msg \
+_(SCTP_ADD_SRC_DST_CONNECTION, sctp_add_src_dst_connection) \
+_(SCTP_DEL_SRC_DST_CONNECTION, sctp_del_src_dst_connection)
static void
vl_api_sctp_add_src_dst_connection_t_handler
@@ -63,6 +64,23 @@ static void
REPLY_MACRO (VL_API_SCTP_ADD_SRC_DST_CONNECTION_REPLY);
}
+static void
+ vl_api_sctp_del_src_dst_connection_t_handler
+ (vl_api_sctp_del_src_dst_connection_t * mp)
+{
+ vl_api_sctp_del_src_dst_connection_reply_t *rmp;
+ int rv;
+
+ if (mp->is_ipv6)
+ rv = sctp_sub_connection_del_ip6
+ ((ip6_address_t *) mp->src_address, (ip6_address_t *) mp->dst_address);
+ else
+ rv = sctp_sub_connection_del_ip4
+ ((ip4_address_t *) mp->src_address, (ip4_address_t *) mp->dst_address);
+
+ REPLY_MACRO (VL_API_SCTP_ADD_SRC_DST_CONNECTION_REPLY);
+}
+
#define vl_msg_name_crc_list
#include <vnet/sctp/sctp.api.h>
#undef vl_msg_name_crc_list
n397'>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