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

Add bind support #493

Merged
merged 8 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

## Unreleased
### Enhancements
- Add bind support to get the listening ip and port of a server. ([#493](https://github.com/KindlingProject/kindling/pull/493))
- Add an option `enable_fetch_replicaset` to control whether to fetch ReplicaSet metadata. The default value is false which aims to release pressure on Kubernetes API server. ([#492](https://github.com/KindlingProject/kindling/pull/492))

### Bug fixes
Expand Down
4 changes: 2 additions & 2 deletions collector/pkg/component/receiver/cgoreceiver/cgo_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ struct kindling_event_t_for_go{
char *directory;
uint32_t protocol;
uint8_t role;
uint32_t sip;
uint32_t dip;
uint32_t sip[4];
uint32_t dip[4];
uint32_t sport;
uint32_t dport;

Expand Down
8 changes: 6 additions & 2 deletions collector/pkg/component/receiver/cgoreceiver/cgoreceiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,12 @@ func convertEvent(cgoEvent *CKindlingEventForGo) *model.KindlingEvent {
ev.Ctx.FdInfo.Filename = C.GoString(cgoEvent.context.fdInfo.filename)
ev.Ctx.FdInfo.Directory = C.GoString(cgoEvent.context.fdInfo.directory)
ev.Ctx.FdInfo.Role = If(cgoEvent.context.fdInfo.role != 0, true, false).(bool)
ev.Ctx.FdInfo.Sip = []uint32{uint32(cgoEvent.context.fdInfo.sip)}
ev.Ctx.FdInfo.Dip = []uint32{uint32(cgoEvent.context.fdInfo.dip)}
ev.Ctx.FdInfo.Sip = make([]uint32, 4)
ev.Ctx.FdInfo.Dip = make([]uint32, 4)
for i := 0; i < 4; i++ {
ev.Ctx.FdInfo.Sip[i] = uint32(cgoEvent.context.fdInfo.sip[i])
ev.Ctx.FdInfo.Dip[i] = uint32(cgoEvent.context.fdInfo.dip[i])
}
ev.Ctx.FdInfo.Sport = uint32(cgoEvent.context.fdInfo.sport)
ev.Ctx.FdInfo.Dport = uint32(cgoEvent.context.fdInfo.dport)
ev.Ctx.FdInfo.Source = uint64(cgoEvent.context.fdInfo.source)
Expand Down
307 changes: 0 additions & 307 deletions probe/src/cgo/defination.h

This file was deleted.

24 changes: 21 additions & 3 deletions probe/src/cgo/kindling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,32 @@ int getEvent(void** pp_kindling_event) {
break;
}
case SCAP_FD_IPV4_SOCK:
case SCAP_FD_IPV4_SERVSOCK:
p_kindling_event->context.fdInfo.protocol = get_protocol(fdInfo->get_l4proto());
p_kindling_event->context.fdInfo.role = fdInfo->is_role_server();
p_kindling_event->context.fdInfo.sip = fdInfo->m_sockinfo.m_ipv4info.m_fields.m_sip;
p_kindling_event->context.fdInfo.dip = fdInfo->m_sockinfo.m_ipv4info.m_fields.m_dip;
p_kindling_event->context.fdInfo.sip[0] = fdInfo->m_sockinfo.m_ipv4info.m_fields.m_sip;
p_kindling_event->context.fdInfo.dip[0] = fdInfo->m_sockinfo.m_ipv4info.m_fields.m_dip;
p_kindling_event->context.fdInfo.sport = fdInfo->m_sockinfo.m_ipv4info.m_fields.m_sport;
p_kindling_event->context.fdInfo.dport = fdInfo->m_sockinfo.m_ipv4info.m_fields.m_dport;
break;
case SCAP_FD_IPV4_SERVSOCK:
p_kindling_event->context.fdInfo.protocol = get_protocol(fdInfo->get_l4proto());
p_kindling_event->context.fdInfo.role = fdInfo->is_role_server();
p_kindling_event->context.fdInfo.dip[0] = fdInfo->m_sockinfo.m_ipv4serverinfo.m_ip;
p_kindling_event->context.fdInfo.dport = fdInfo->m_sockinfo.m_ipv4serverinfo.m_port;
break;
case SCAP_FD_IPV6_SOCK:
p_kindling_event->context.fdInfo.protocol = get_protocol(fdInfo->get_l4proto());
dxsup marked this conversation as resolved.
Show resolved Hide resolved
p_kindling_event->context.fdInfo.role = fdInfo->is_role_server();
memcpy(p_kindling_event->context.fdInfo.sip, fdInfo->m_sockinfo.m_ipv6info.m_fields.m_sip.m_b, sizeof(fdInfo->m_sockinfo.m_ipv6info.m_fields.m_sip.m_b));
memcpy(p_kindling_event->context.fdInfo.dip, fdInfo->m_sockinfo.m_ipv6info.m_fields.m_dip.m_b, sizeof(fdInfo->m_sockinfo.m_ipv6info.m_fields.m_dip.m_b));
p_kindling_event->context.fdInfo.sport = fdInfo->m_sockinfo.m_ipv6info.m_fields.m_sport;
p_kindling_event->context.fdInfo.dport = fdInfo->m_sockinfo.m_ipv6info.m_fields.m_dport;
break;
case SCAP_FD_IPV6_SERVSOCK:
p_kindling_event->context.fdInfo.role = fdInfo->is_role_server();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't set p_kindling_event->context.fdInfo.protocol = get_protocol(fdInfo->get_l4proto());

memcpy(p_kindling_event->context.fdInfo.dip, fdInfo->m_sockinfo.m_ipv6serverinfo.m_ip.m_b, sizeof(fdInfo->m_sockinfo.m_ipv6serverinfo.m_ip.m_b));
p_kindling_event->context.fdInfo.dport = fdInfo->m_sockinfo.m_ipv6serverinfo.m_port;
break;
case SCAP_FD_UNIX_SOCK:
p_kindling_event->context.fdInfo.source = fdInfo->m_sockinfo.m_unixinfo.m_fields.m_source;
p_kindling_event->context.fdInfo.destination =
Expand Down
4 changes: 2 additions & 2 deletions probe/src/cgo/kindling.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ struct kindling_event_t_for_go {
char* directory;
uint32_t protocol;
uint8_t role;
uint32_t sip;
uint32_t dip;
uint32_t sip[4];
uint32_t dip[4];
uint32_t sport;
uint32_t dport;
uint64_t source;
Expand Down