Add/Parse Geneve Option for Multicast Tag

Đang mở
#760 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@zeeshanlakhani đang làm issue này rồi.

Từ ngày 25/5/2025.

  • #847 của @FelixMcFelix — đã đóng, không merge

Đánh giá

Issue này chưa được đánh giá.

Mô tả

multicast

With the additional Geneve option added as part of Multicast replication in https://github.com/oxidecomputer/dendrite/pull/14, we need to update the Geneve engine in OPTE to parse and set this option.

Here's the P4 code showing the additions:

const bit<7> GENEVE_OPT_OXIDE_MCAST	= 0x01;
/* Geneve option for an `mcast_tag`.
 * This is a 2-bit field that indicates the type of
 * multicast traffic:
 * 0 - Replicate packets to ports set for external multicast traffic
 * 1 - Replicate packets to ports set for underlay multicast traffic
 * 2 - Replicate packets to ports set for underlay and external multicast
       traffic (bifurcated)
 *
 * The rest of the option is reserved.
*/
header geneve_opt_mcast_h {
	bit<2> mcast_tag;
	bit<30> reserved;
}
struct geneve_opt_headers_t {
	geneve_opt_h	ox_external_tag;
	geneve_opt_h ox_external_tag;
	// Multicast-specific options
	geneve_opt_mcast_h ox_mcast_tag;
}

Here's a test helper used in packet testing to generate the option as part of a Geneve (encapsulated) packet:

/// Build a Geneve packet with a possible multicast tag.
pub fn gen_geneve_packet_with_mcast_tag(
    src: Endpoint,
    dst: Endpoint,
    inner_type: u16,
    vni: u32,
    tag_ingress: bool,
    mcast_tag: Option<u8>, // New parameter for multicast tag
    payload: &[u8],
) -> Packet {
    let udp_stack = match src.get_ip("src").unwrap() {
        IpAddr::V4(_) => {
            vec![inner_type, ipv4::IPPROTO_UDP.into(), eth::ETHER_IPV4]
        }
        IpAddr::V6(_) => {
            vec![inner_type, ipv6::IPPROTO_UDP.into(), eth::ETHER_IPV6]
        }
    };

    let mut pkt = Packet::gen(src, dst, udp_stack, Some(payload)).unwrap();
    let geneve = pkt.hdrs.geneve_hdr.as_mut().unwrap();
    geneve.vni = vni;

    match (tag_ingress, mcast_tag) {
        (true, Some(tag)) if tag < 3 => {
            geneve.opt_len = 2;
            // Multicast tag option
            #[rustfmt::skip]
            geneve.options.extend_from_slice(&[
                // First 2 bytes: Geneve option class (0x0129)
                // The OXIDE vendor-specific class identifier
                0x01, 0x29,
                // Third byte: Critical bit (0) + Option type (1)
                // Type 1 represents multicast tagged packets
                0x01,
                // Fourth byte: Option(s) length
                0x01,
                // Fifth byte: Tag value (encoded in the data)
                (tag & 0x03) << 6,
                // Sixth byte: reserved
                0x00,
                // Seventh byte
                0x00,
                // Eighth byte
                0x00,
            ]);

            let extra_bytes = geneve.options.len() as u16;

            match src.get_ip("src").unwrap() {
                IpAddr::V4(_) => {
                    pkt.hdrs.ipv4_hdr.as_mut().unwrap().ipv4_total_len +=
                        extra_bytes
                }
                IpAddr::V6(_) => {
                    pkt.hdrs.ipv6_hdr.as_mut().unwrap().ipv6_payload_len +=
                        extra_bytes
                }
            }

            pkt.hdrs.udp_hdr.as_mut().unwrap().udp_len += extra_bytes;
        }
        (true, Some(_)) => {
            // Multicast tag is not valid
            panic!("Multicast tag must be less than 3");
        }
        (true, None) => {
            // External packet option
            geneve.opt_len = 1;
            #[rustfmt::skip]
            geneve.options.extend_from_slice(&[
                // First 2 bytes: Geneve option class (0x0129)
                // The OXIDE vendor-specific class identifier
                0x01, 0x29,
                // Third byte: Critical bit (0) + Option type (1)
                0x00,
                // reserved + body len
                0x00,
            ]);

            let extra_bytes = geneve.options.len() as u16;

            match src.get_ip("src").unwrap() {
                IpAddr::V4(_) => {
                    pkt.hdrs.ipv4_hdr.as_mut().unwrap().ipv4_total_len +=
                        extra_bytes
                }
                IpAddr::V6(_) => {
                    pkt.hdrs.ipv6_hdr.as_mut().unwrap().ipv6_payload_len +=
                        extra_bytes
                }
            }

            pkt.hdrs.udp_hdr.as_mut().unwrap().udp_len += extra_bytes;
        }
        _ => {}
    }

    pkt
}
Ngôn ngữ chính
Rust
Star
82
Fork
16
Merge trung bình
3 ngày 6 giờ
Pull request đã merge (30 ngày)
11

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của oxidecomputer/opte

Tất cả issue của oxidecomputer/opte

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.