mengdemao / lazybsd

用户态网络库实现
https://mengdemao.github.io/lazybsd/
BSD 3-Clause "New" or "Revised" License
4 stars 2 forks source link

frebsd repo文件内容修改 #20

Closed mengdemao closed 1 month ago

mengdemao commented 1 month ago

lazybsd补丁文件分析

使用HAVE_LAZYBSD配置功能

alias_sctp.h头文件

struct sctp_nat_msg {
    uint16_t msg;           /**< one of the key messages defined above */
#if defined(INET6) && !defined(LAZYBSD)
    //  struct ip6_hdr *ip_hdr; /**< pointer to ip packet header */ /*no inet6 support yet*/
#else
    struct ip *ip_hdr;      /**< pointer to ip packet header */
#endif //#ifdef INET6
    struct sctphdr *sctp_hdr;   /**< pointer to sctp common header */
    union sctpChunkOfInt sctpchnk; /**< union of pointers to the chunk of interest */
    int chunk_length;       /**< length of chunk of interest */
};

system.h头文件

#ifndef LAZYBSD
#include <sys/kpilite.h>
#endif

临界区

static __inline void
critical_enter(void)
{
#ifndef LAZYBSD
    struct thread_lite *td;

    td = (struct thread_lite *)curthread;
    td->td_critnest++;
    atomic_interrupt_fence();
#endif /* LAZYBSD */
}

static __inline void
critical_exit(void)
{
#ifndef LAZYBSD
    struct thread_lite *td;

    td = (struct thread_lite *)curthread;
    KASSERT(td->td_critnest != 0,
        ("critical_exit: td_critnest == 0"));
    atomic_interrupt_fence();
    td->td_critnest--;
    atomic_interrupt_fence();
    if (__predict_false(td->td_owepreempt))
        critical_exit_preempt();
#endif /* LAZYBSD */
}