这是indexloc提供的服务,不要输入任何密码
Skip to content

XDP_UMEM_PGOFF_FILL_RING and XDP_UMEM_PGOFF_COMPLETION_RING have an incorrect/inconsistent type #4821

@nahla-nee

Description

@nahla-nee

The code below would fail to compile because XDP_UMEM_PGOFF_FILL_RING and XDP_UMEM_PGOFF_COMPLETION_RING are of type c_ulonglong (u64) while XDP_PGOFF_RX_RING and XDP_PGOFF_TX_RING are of type off_t (i64).

enum RingBufferType {
    XdpRx,
    XdpTx,
    XdpFill,
    XdpCompletion
}

impl RingBufferType {
    fn get_mmap_offset(&self) -> libc::off_t {
        match self {
            RingBufferType::XdpRx => libc::XDP_PGOFF_RX_RING,
            RingBufferType::XdpTx => libc::XDP_PGOFF_TX_RING,
            RingBufferType::XdpFill => libc::XDP_UMEM_PGOFF_FILL_RING,
            RingBufferType::XdpCompletion => libc::XDP_UMEM_PGOFF_COMPLETION_RING,
        }
    }
}

Considering that these constants are used for mmap calls in the position of the offset parameter they should all be off type off_t as that is what mmap expects. This can currently be worked around by simple casting the constant with as.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions