ff_recvfrom failed: Operation not permitted

Question:

I am writing a UDP socket application using F-Stack, but I am facing an issue with the ff_recvfrom call. The ff_recvfrom function fails even after successfully creating and binding the socket. Below, I’ve provided the complete code, configuration file, terminal output, and DPDK status.

I am unsure whether the issue lies in my configuration or how the socket is being used.

my code :

// Here's the context:

    I am using F-Stack, which is designed to accelerate network applications in user space by leveraging DPDK for packet processing.
    The socket is successfully created with ff_socket and bound using ff_bind, but when I try to receive data with ff_recvfrom, it fails.
    The application is supposed to listen for UDP packets on a specified IP and port.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <ff_api.h>

#define PORT 12345
#define BUFFER_SIZE 1024
#define IP_ADDRESS "192.168.1.3"

int main(int argc, char *argv[]) {
    if (ff_init(argc, argv) < 0) {
        fprintf(stderr, "F-Stack initialization failedn");
        return -1;
    }

    int sock = ff_socket(AF_INET, SOCK_DGRAM, 0);
    if (sock < 0) {
        perror("ff_socket failed");
        return -1;
    }

    struct linux_sockaddr server_addr;
    memset(&server_addr, 0, sizeof(server_addr));
    server_addr.sa_family = AF_INET;

    *((uint16_t *)server_addr.sa_data) = htons(PORT);
    inet_pton(AF_INET, IP_ADDRESS, server_addr.sa_data + 2);

    if (ff_bind(sock, &server_addr, sizeof(server_addr)) < 0) {
        perror("ff_bind failed");
        ff_close(sock);
        return -1;
    }

    printf("Listening for UDP packets on port %d...n", PORT);

    char buffer[BUFFER_SIZE];
    struct linux_sockaddr from_addr;
    socklen_t from_len = sizeof(from_addr);

    while (1) {
        ssize_t received_bytes = ff_recvfrom(sock, buffer, BUFFER_SIZE - 1, 0,
                                             (struct linux_sockaddr *)&from_addr, &from_len);
        if (received_bytes < 0) {
            perror("ff_recvfrom failed");
            break;
        }

        buffer[received_bytes] = '';

        printf("Received %ld bytes from %s:%d: %sn", received_bytes,
               inet_ntoa(*(struct in_addr *)&from_addr.sa_data[4]), ntohs(*(uint16_t *)&from_addr.sa_data[2]), buffer);
    }

    ff_close(sock);

    return 0;
}

Configuration File (config.ini):

[dpdk]
lcore_mask=0x3  
channel=2
promiscuous=1
numa_on=0
tcore_mask=0x3
port_list=0
mem_size=4096

[port0]
addr=192.168.1.3
netmask=255.255.255.0
broadcast=192.168.1.255
gateway=192.168.1.254
#addr6 = fe80::a8:6501:12f1:3eb9
#prefix6 = 64
#gateway6 = fe80::1

[log]
level = debug

Terminal output :
Terminal

DPDK Status (dpdk-devbind.py –status):

Network devices using DPDK-compatible driver
============================================
0000:00:08.0 '82540EM Gigabit Ethernet Controller 100e' drv=uio_pci_generic unused=e1000

Network devices using kernel driver
===================================
0000:00:03.0 '82540EM Gigabit Ethernet Controller 100e' if=enp0s3 drv=e1000 unused=uio_pci_generic *Active*

No 'Baseband' devices detected
==============================

No 'Crypto' devices detected
============================

No 'DMA' devices detected
=========================

No 'Eventdev' devices detected
==============================

No 'Mempool' devices detected
=============================

No 'Compress' devices detected
==============================

No 'Misc (rawdev)' devices detected
===================================

No 'Regex' devices detected
===========================

Things I’ve Tried:

Checked if the IP address and port are being used by another application.
Reviewed the config.ini file settings for addr, netmask, and gateway.
Verified the DPDK status to make sure the correct network card is being used.

Issue:

The ff_recvfrom function fails, but the socket has been successfully created and bound.
The IP address used is 192.168.1.3.
The network card seems to be correctly set up.

Any help would be greatly appreciated!

New contributor

user28941695 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật