IPVS代码阅读笔记(一):重要数据结构

本文详细解读了IPVS的三个关键数据结构:ip_vs_service、ip_vs_dest和ip_vs_conn,包括它们的用途、字段信息及在IPVS服务中的作用,如服务对象的监听信息、真实服务器列表和连接管理。
摘要由CSDN通过智能技术生成
IPVS是基于Netfilter框架实现的内核模块。它实现了IP层的负载均衡功能。IPVS完全在内核态实现,效率非常高。IPVS的官方网站: www.linuxvirtualserver.org
 
首先来看一下IPVS模块的一些重要数据结构。
 

1、ip_vs_service结构

ip_vs_service结构代表的是一个IPVS服务对象,它包含了IPVS服务的监听地址、端口、协议和调度算法等信息。

/*
 *    The information about the virtual service offered to the net
 *    and the forwarding entries
 */

struct ip_vs_service {
    struct list_head    s_list; /* for normal service table */
    struct list_head    f_list; /* for fwmark-based service table */
    atomic_t        refcnt; /* reference counter */
    atomic_t        usecnt; /* use counter */

    __u16            protocol; /* which protocol (TCP/UDP) */
    __u32            addr;     /* IP address for virtual service */
    __u16            port;     /* port number for the service */
    __u32 fwmark; /* firewall mark of the service */
    unsigned        flags;     /* service status flags */
    unsigned        timeout; /* persistent timeout in ticks */
    __u32            netmask; /* grouping granularity */

    struct list_head    destinations; /* real server d-linked list */
    __u32            num_dests; /* number of servers */

    struct ip_vs_stats stats; /* statistics for the service */
    struct ip_vs_app    *inc;     /* bind conns to this app inc */

    /* for scheduling */
    struct ip_vs_scheduler    *scheduler; /* bound scheduler object */
    rwlock_t        sch

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值