summaryrefslogtreecommitdiffstats
path: root/src/plugins/sixrd/ip4_sixrd.c
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2018-03-08 12:30:43 +0100
committerNeale Ranns <nranns@cisco.com>2018-03-14 14:06:02 +0000
commit298c69510ff4b64a262d465eb8877c4e7f4e60e0 (patch)
treee9ecf5fe32203ff40798841ac6442c9eaca943ca /src/plugins/sixrd/ip4_sixrd.c
parent1c5ddbb22ba37e022a4cbf7c23d3cf6490d8ac6e (diff)
IPIP: Add IP{v4,v6} over IP{v4,v6} configured tunnel support.
Change-Id: I166301c9e2388bae5f70ec0179d663a2703e27f5 Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/plugins/sixrd/ip4_sixrd.c')
-rw-r--r--src/plugins/sixrd/ip4_sixrd.c165
1 files changed, 0 insertions, 165 deletions
diff --git a/src/plugins/sixrd/ip4_sixrd.c b/src/plugins/sixrd/ip4_sixrd.c
deleted file mode 100644
index f700f14978c..00000000000
--- a/src/plugins/sixrd/ip4_sixrd.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/*---------------------------------------------------------------------------
- * Copyright (c) 2009-2014 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *---------------------------------------------------------------------------
- */
-
-#include "sixrd.h"
-
-vlib_node_registration_t ip4_sixrd_node;
-
-typedef enum {
- IP4_SIXRD_NEXT_IP6_LOOKUP,
- IP4_SIXRD_NEXT_DROP,
- IP4_SIXRD_N_NEXT,
-} ip4_sixrd_next_t;
-
-typedef struct {
- u32 tunnel_id;
- u32 length;
- ip4_address_t src;
- ip4_address_t dst;
-} sixrd_rx_trace_t;
-
-u8 *
-format_sixrd_rx_trace (u8 * s, va_list * args)
-{
- CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
- CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- sixrd_rx_trace_t *t = va_arg (*args, sixrd_rx_trace_t *);
-
- s = format (s, "6RD: tunnel %d len %d src %U dst %U",
- t->tunnel_id, clib_net_to_host_u16 (t->length),
- format_ip4_address, &t->src, format_ip4_address, &t->dst);
- return s;
-}
-
-/*
- * ip4_sixrd_sec_check
- */
-static_always_inline void
-ip4_sixrd_sec_check(sixrd_tunnel_t *t, ip4_address_t sa4,
- ip6_address_t sa6, u8 *error) {
- if (PREDICT_FALSE(sixrd_get_addr_net(t, sa6.as_u64[0]) != sa4.as_u32))
- *error = SIXRD_ERROR_SEC_CHECK;
-}
-
-/*
- * ip4_sixrd
- */
-uword ip4_sixrd(vlib_main_t *vm, vlib_node_runtime_t *node,
- vlib_frame_t *frame) {
- u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
- vlib_node_runtime_t *error_node = vlib_node_get_runtime(vm, ip4_sixrd_node.index);
- vnet_interface_main_t * im = &vnet_get_main()->interface_main;
- u32 thread_index = vlib_get_thread_index ();
-
- from = vlib_frame_vector_args(frame);
- n_left_from = frame->n_vectors;
- next_index = node->cached_next_index;
- while (n_left_from > 0) {
- vlib_get_next_frame(vm, node, next_index, to_next, n_left_to_next);
-
- /* Single loop */
- while (n_left_from > 0 && n_left_to_next > 0) {
- u32 pi0;
- vlib_buffer_t *p0;
- u8 error0 = SIXRD_ERROR_NONE;
- sixrd_tunnel_t *t0 = 0;
- ip4_header_t *ip40;
- ip6_header_t *ip60;
- u32 tunnel_sw_if_index = ~0;
- u32 next0 = IP4_SIXRD_NEXT_DROP;
-
- pi0 = to_next[0] = from[0];
- from += 1;
- n_left_from -= 1;
- to_next += 1;
- n_left_to_next -= 1;
-
- p0 = vlib_get_buffer(vm, pi0);
- ip40 = vlib_buffer_get_current(p0);
-
- /* Throw away anything that isn't IP in IP. */
- if (PREDICT_TRUE(ip40->protocol == IP_PROTOCOL_IPV6 && clib_net_to_host_u16(ip40->length) >= 60)) {
- vlib_buffer_advance(p0, sizeof(ip4_header_t));
- t0 = ip4_sixrd_get_tunnel(vnet_buffer(p0)->ip.adj_index[VLIB_TX], (ip4_address_t *)&ip40->dst_address, &error0);
- } else {
- error0 = SIXRD_ERROR_BAD_PROTOCOL;
- }
-
- if (!t0) {
- error0 = SIXRD_ERROR_NO_TUNNEL;
- goto error;
- }
-
- tunnel_sw_if_index = t0->sw_if_index;
-
- /* SIXRD inbound security check */
- if (t0->security_check) {
- ip60 = vlib_buffer_get_current(p0);
- ip4_sixrd_sec_check(t0, ip40->src_address, ip60->src_address, &error0);
- }
- next0 = error0 == SIXRD_ERROR_NONE ? IP4_SIXRD_NEXT_IP6_LOOKUP
- : IP4_SIXRD_NEXT_DROP;
-
- if (PREDICT_FALSE(p0->flags & VLIB_BUFFER_IS_TRACED)) {
- sixrd_rx_trace_t *tr = vlib_add_trace(vm, node, p0, sizeof(*tr));
- tr->tunnel_id = tunnel_sw_if_index;
- tr->length = ip40->length;
- tr->src.as_u32 = ip40->src_address.as_u32;
- tr->dst.as_u32 = ip40->dst_address.as_u32;
- }
-
- error:
- if (PREDICT_TRUE(error0 == SIXRD_ERROR_NONE)) {
- u32 len = vlib_buffer_length_in_chain (vm, p0);
- vlib_increment_combined_counter (im->combined_sw_if_counters
- + VNET_INTERFACE_COUNTER_RX,
- thread_index,
- tunnel_sw_if_index,
- 1 /* packets */ ,
- len /* bytes */ );
-
- vnet_buffer (p0)->sw_if_index[VLIB_RX] = tunnel_sw_if_index;
- } else {
- p0->error = error_node->errors[error0];
- }
- vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next,
- n_left_to_next, pi0, next0);
- }
- vlib_put_next_frame(vm, node, next_index, n_left_to_next);
- }
- return frame->n_vectors;
-}
-
-static char *sixrd_error_strings[] = {
-#define _(sym, string) string,
- foreach_sixrd_error
-#undef _
-};
-
-VLIB_REGISTER_NODE(ip4_sixrd_node) = {
- .function = ip4_sixrd,
- .name = "ip4-sixrd",
- .vector_size = sizeof(u32),
- .format_trace = format_sixrd_rx_trace,
- .n_errors = SIXRD_N_ERROR,
- .error_strings = sixrd_error_strings,
- .n_next_nodes = IP4_SIXRD_N_NEXT,
- .next_nodes =
- {
- [IP4_SIXRD_NEXT_IP6_LOOKUP] = "ip6-lookup",
- [IP4_SIXRD_NEXT_DROP] = "error-drop",
- },
-};
45' href='#n445'>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 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820