dpvs.conf 配置文件说明

推荐一个chatgpt代理站(支持gpt4): www.gptschools.cn

1. dpvs.conf 配置文件说明

本文是对dpvs默认配置文件的解释说明。

  • 在DPVS的配置文件中,<init>表示初始化阶段的配置项,无法重新加载。 如果配置了无效值! 文件,dpvs将使用其默认值。
  • 注释行: 以#或者!。内联范围注释:使用“ <”和“>”,在两者之间添加注释。

1.1. 全局

## 日志级别、日志路径
global_defs { 
    log_level   WARNING
    !log_file    /var/log/dpvs.log
## 是否开启异步模式
    ! log_async_mode    on
}

1.2. 网卡设备

配置网卡的接收、发送队列数,RSS、FDir的模式。
注意:FDir的匹配域不在dpvs配置文件中配置,而是在C文件中,以静态变量的形式配置。

netif_defs {

    <init> pktpool_size     2097151  // 内存池相关
    <init> pktpool_cache    256
    /* 网卡设备 */
    <init> device dpdk0 {  
        rx {
            queue_number        8
            descriptor_number   1024
            rss                 tcp  // 接收队列配置RSS
        }
        tx {
            queue_number        8
            descriptor_number   1024
        }
        fdir { // 配置网卡dpdk0的Fdir
            mode                perfect
            pballoc             64k
            status              matched
        }
    !    promisc_mode
        kni_name                dpdk0.kni
    }
}

1.3. 工作核心

worker_defs {
    <init> worker cpu0 {  
        type    master // master核,管理核
        cpu_id  0
    }
    <init> worker cpu1 {
        type    slave  // slave核,处理业务
        cpu_id  1
        port    dpdk0 { // port即为网卡
            rx_queue_ids     0 // 接收队列号
            tx_queue_ids     0 // 发送队列号
            ! isol_rx_cpu_ids  9  // 表示当前 lcore 专职负责接收数据
            ! isol_rxq_ring_sz 1048576  // 专职接收数据的 ring buffer 大小
        }
        port    dpdk1 {
            rx_queue_ids     0
            tx_queue_ids     0
            ! isol_rx_cpu_ids  9
            ! isol_rxq_ring_sz 1048576
        }
    }
}

1.4. ipv4

ipv4_defs {
    <init> ipv4_forward off // set this to on, dpvs will forward packets that NOT hit rules directly
    <init> default_ttl         64
    fragment {
        <init> bucket_number   4096
        <init> bucket_entries  16
        <init> max_entries     4096
        <init> ttl             1
    }
}

1.5. ipv6

! dpvs ipv6 config
ipv6_defs {
    disable                     off
    forwarding                  off
    route6 {
        <init> method           hlist
        recycle_time            10
    }
}

1.6. 定时器相关

timer_defs {
    // cpu job loops to schedule dpdk timer management
    schedule_interval    500
}

1.7. 邻居子系统

由于自己实现 tcp 协义,那邻居子系统和路由系统肯定也要实现,只不过比较精简专用

neigh_defs {
    <init> unres_queue_length  128
    <init> timeout             60
}

1.8. 控制配置

ctrl_defs {
    lcore_msg {
        <init> ring_size                4096
        <init> multicast_queue_length   256
        sync_msg_timeout_us             2000
    }
    ipc_msg { // 与dpvs同学的unix接口文件
        <init> unix_domain /var/run/dpvs_ctrl
    }
}

1.9. ipvs

! ipvs config
ipvs_defs {
    conn {
        <init> conn_pool_size       2097152
        <init> conn_pool_cache      256
        conn_init_timeout           3
        ! expire_quiescent_template
        ! fast_xmit_close
        ! <init> redirect           off
    }

    udp {
        ! defence_udp_drop
        uoa_mode        opp  // uoa模式,携带client_ip
        uoa_max_trail   3
        timeout {  // 配置 udp 的超时时间
            normal      300
            last        3
        }
    }

    tcp {
        ! defence_tcp_drop
        timeout { // 配置tcp不同状态的超时时间
            none        2
            established 90
            syn_sent    3
            syn_recv    30
            fin_wait    7
            time_wait   7
            close       3
            close_wait  7
            last_ack    7
            listen      120
            synack      30
            last        2
        }
        synproxy {
            synack_options {
                mss             1452
                ttl             63
                sack
                ! wscale
                ! timestamp
            }
            ! defer_rs_syn
            rs_syn_max_retry    3
            ack_storm_thresh    10
            max_ack_saved       3
            conn_reuse_state {
                close
                time_wait
                ! fin_wait
                ! close_wait
                ! last_ack
           }
        }
    }
}

1.10. sa_pool

sa_pool是 socket address (or local <ip, port> pair) pool 的缩写。

对于多核应用程序,流量返回本地启动的连接需要达到原CPU核心。有几个实现目标的方法。一种是用同样的方法计算RSS,NIC选择当前CPU进行连接。dpvs使用的方法是基于Flow Director(fdir),预先为每个CPU核心提供本地源<ip,端口>。并通过fdir将后端通信量重定向到该CPU。

! sa_pool config
sa_pool {
    pool_hash_size   16
}

每个 lcore 有自己的 sa_pool, 用于管理本地分配的 <lip, lport>, 假如当前启用了 64 个 lcore, 一共有 65535-1024 可用端口,那么每个 lcore 在同一个 lip 上最多使用 (65535-1024)/64 个地址。

2. 端口RSS/FDir 配置

端口RSS/FDir 的默认配置在文件dpvs/blob/master/src/netif.c中,

RSS/FDir配置:

static struct rte_eth_conf default_port_conf = {
    .rxmode = {
        .mq_mode        = ETH_MQ_RX_RSS,
        .max_rx_pkt_len = ETHER_MAX_LEN,
        .split_hdr_size = 0,
        .offloads = DEV_RX_OFFLOAD_IPV4_CKSUM,
    },
    /* 接收队列RSS配置 */
    .rx_adv_conf = {
        .rss_conf = {
            .rss_key = NULL,
            .rss_hf  = /*ETH_RSS_IP*/ ETH_RSS_TCP,  // RSS默认使用ETH_RSS_TCP
        },
    },
    .txmode = {
        .mq_mode = ETH_MQ_TX_NONE,
    },
    /* fdir配置 */
    .fdir_conf = {
        .mode    = RTE_FDIR_MODE_PERFECT,
        .pballoc = RTE_FDIR_PBALLOC_64K,
        .status  = RTE_FDIR_REPORT_STATUS/*_ALWAYS*/,
        .mask    = {
            .vlan_tci_mask      = 0x0, // 忽略 vlan id
            .ipv4_mask          = {
                .src_ip         = 0x00000000, // 忽略 src_ip
                .dst_ip         = 0xFFFFFFFF,  // 匹配dst ip
            },
            .ipv6_mask          = {
                .src_ip         = { 0, 0, 0, 0 }, // 忽略 src ipv6
                .dst_ip         = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }, // 匹配 dst ipv6
            },
            .src_port_mask      = 0x0000, // 忽略 src port

            /* to be changed according to slave lcore number in use */
            .dst_port_mask      = 0x00F8, // 1111 1000‬, 非零,根据掩码匹配

            .mac_addr_byte_mask = 0x00,
            .tunnel_type_mask   = 0,
            .tunnel_id_mask     = 0,
        },
        .drop_queue             = 127,
        .flex_conf              = {
            .nb_payloads        = 0,
            .nb_flexmasks       = 0,
        },
    },
};

可见,上述fdir配置中, dpvs根据 dst_ip, dst_port_mask 计算,也就是对应 <lip, lport>, 若 lip 只有一个,所以等同于只看 lport,

原文地址:DPVS配置说明

3. 参考

posted @ 2020-03-11 21:19  可酷可乐  阅读(2147)  评论(0编辑  收藏  举报