Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dns) 实现 DNS 解析事件的捕获 #72

Closed
2 tasks
Ghostbaby opened this issue Sep 27, 2024 · 1 comment · Fixed by #73
Closed
2 tasks

feat(dns) 实现 DNS 解析事件的捕获 #72

Ghostbaby opened this issue Sep 27, 2024 · 1 comment · Fixed by #73
Assignees

Comments

@Ghostbaby
Copy link
Collaborator

Ghostbaby commented Sep 27, 2024

功能:

  • 完整 ebpf example dns failure 的代码的移植
  • 完成多内核的适配
@Ghostbaby Ghostbaby self-assigned this Sep 27, 2024
@Ghostbaby Ghostbaby pinned this issue Sep 27, 2024
@Ghostbaby
Copy link
Collaborator Author

Ghostbaby commented Sep 27, 2024

struct iov_iter 内存布局发生变化
内核 4.19

struct iov_iter {
        unsigned int               type;                 /*     0     4 */

        /* XXX 4 bytes hole, try to pack */

        size_t                     iov_offset;           /*     8     8 */
        size_t                     count;                /*    16     8 */ 
        union {                    
                const struct iovec  * iov;               /*    24     8 */
                const struct kvec  * kvec;               /*    24     8 */
                const struct bio_vec  * bvec;            /*    24     8 */
                struct pipe_inode_info * pipe;           /*    24     8 */
        };                                               /*    24     8 */
        union {
                long unsigned int  nr_segs;              /*    32     8 */
                struct {
                        int        idx;                  /*    32     4 */
                        int        start_idx;            /*    36     4 */
                };                                       /*    32     8 */
        };                                               /*    32     8 */

        /* size: 40, cachelines: 1, members: 5 */
        /* sum members: 36, holes: 1, sum holes: 4 */
        /* last cacheline: 40 bytes */
};

内核 5.10

struct iov_iter {
        u8                         iter_type;            /*     0     1 */
        bool                       nofault;              /*     1     1 */
        bool                       data_source;          /*     2     1 */

        /* XXX 5 bytes hole, try to pack */

        size_t                     iov_offset;           /*     8     8 */
        size_t                     count;                /*    16     8 */
        union {
                const struct iovec  * iov;               /*    24     8 */
                const struct kvec  * kvec;               /*    24     8 */
                const struct bio_vec  * bvec;            /*    24     8 */
                struct xarray *    xarray;               /*    24     8 */
                struct pipe_inode_info * pipe;           /*    24     8 */
        };                                               /*    24     8 */
        union {
                long unsigned int  nr_segs;              /*    32     8 */
                struct {
                        unsigned int head;               /*    32     4 */
                        unsigned int start_head;         /*    36     4 */
                };                                       /*    32     8 */
                loff_t             xarray_start;         /*    32     8 */
        };                                               /*    32     8 */

        /* size: 40, cachelines: 1, members: 7 */
        /* sum members: 35, holes: 1, sum holes: 5 */
        /* last cacheline: 40 bytes */
};

内核 6.8

struct iov_iter {
        u8                         iter_type;            /*     0     1 */
        bool                       nofault;              /*     1     1 */
        bool                       data_source;          /*     2     1 */

        /* XXX 5 bytes hole, try to pack */

        size_t                     iov_offset;           /*     8     8 */
        union {
                struct iovec       __ubuf_iovec;         /*    16    16 */
                struct {
                        union {    
                                const struct iovec  * __iov; /*    16     8 */
                                const struct kvec  * kvec; /*    16     8 */
                                const struct bio_vec  * bvec; /*    16     8 */
                                struct xarray * xarray;  /*    16     8 */
                                void * ubuf;             /*    16     8 */
                        };                               /*    16     8 */
                        size_t     count;                /*    24     8 */
                };                                       /*    16    16 */
        };                                               /*    16    16 */
        union {
                long unsigned int  nr_segs;              /*    32     8 */
                loff_t             xarray_start;         /*    32     8 */
        };                                               /*    32     8 */

        /* size: 40, cachelines: 1, members: 6 */
        /* sum members: 35, holes: 1, sum holes: 5 */
        /* last cacheline: 40 bytes */
};

问题

  1. 通过 iov_iter.iov 获取 DNS 解析的数据,在6.8内核需要处理不兼容的字段。

方案

  1. 参考Handling incompatible field and type changes 章节解决不兼容字段的问题
struct task_struct___old {
    long state;
} __attribute__((preserve_access_index));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant