-
Notifications
You must be signed in to change notification settings - Fork 307
feat: allow mapping multiple domain names to single ip #763
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bpf part lgtm.
但我还是更建议使用 bit field
volatile u8 goodsubrule : 1;
volatile u8 badrule : 1;
volatile u8 must : 1;
u8 isdns : 1;
unused : 4;这样有更明确的 padding 而不会造成结构体空洞。空洞 + llvm 优化 是大量 bpf verifier 报错之源。
(以及为什么要用 volatile?删掉有影响吗?)
jschwinger233
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint 挂了,你在混用 tab 和 space。
volatile 是因为原本就这么写了,我其实不知道这意味着什么 |
2d263ab to
ef810b2
Compare
已经修复 |
4dd0103 to
8b8a68a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧪 Since the PR has been fully tested, please consider merging it.
jschwinger233
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bpf parts lgtm
| (domain_routing->bitmap[index / 32] >> (index % 32)) & 1) | ||
| ctx->isdns_must_goodsubrule_badrule |= 0b10; | ||
| (domain_routing->bitmap[index / 32] >> (index % 32)) & 1) { | ||
| // All domains mapeed by the current IP address are matched. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: typo mapeed
jschwinger233
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
看了一下用户态的代码,有一些小疑问 🙏
| if !badRule { | ||
| if outbound == consts.OutboundControlPlaneRouting { | ||
| continue | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我记得这个函数要和 bpf 的逻辑一致,这个修改在 bpf 里貌似没有?
| if !exists { | ||
| newBumpMap = make([]uint32, consts.MaxMatchSetLen) | ||
| } | ||
| for index := 0; index < consts.MaxMatchSetLen; index++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
似乎有点浪费 cpu 了,大部分用户的规则都不会超过 100 条吧,这里 MaxMatchSetLen 是 1024,可以做个短路 break
| // jump to control plane. | ||
| need_control_plane_routing = true; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这一段逻辑也应该更新到 routing_matcher_userspace.go:Match() ?
| bool must = ctx->must || match_set->must; | ||
|
|
||
| if (!must && ctx->isdns) { | ||
| if ((!must && ctx->isdns) || need_control_plane_routing) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
|
Any updates? |
|
Any updates? |
23337ce
|
求更新 |
Note The following content has been translated from its original language using an automated process powered by a proprietary API. Segments originally written in English have been preserved, while non-English portions have been machine-translated for readability. Please be aware that minor inaccuracies may exist due to the automated nature of the translation. Request for an update. |
|
Are there any plans for mergers in the future? |
Background
当前dae通过观测dns请求来实现domain的路由,例如观测到
google.com的地址为46.82.174.69,则内核部分会将46.82.174.69当作google.com处理,并且用户态会直接计算每条domain规则的匹配结果并直接注入但假设一种情况,
api.bilibili.com和cm.bilibili.com均使用ip61.240.206.12,dae会将61.240.206.12视为最后一次dns查询时的域名,并通过将ttl设置为0并期待每次产生连接前都产生一次dns查询不过假如客户端完全不尊重ttl,那么一切就都乱套了,例如希望对
api.bilibili.com和cm.bilibili.com应用不同的路由,那么这将完全不工作本PR设想了一种全新的方法,完全不依赖TTL,即如果
api.bilibili.com和cm.bilibili.com具有相同的路由(即,同时匹配同一个domain规则),则直接路由61.240.206.12,否则则强制跳入用户态依赖sniff进行重新路由Checklist
目前还非常粗糙,需要充分测试
Full Changelogs
Issue Reference
Closes #[issue number]
Test Result