-
Notifications
You must be signed in to change notification settings - Fork 373
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
[Multicast] removal of stale multicast routes #3242
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3242 +/- ##
==========================================
- Coverage 72.72% 65.58% -7.14%
==========================================
Files 427 390 -37
Lines 66544 59043 -7501
==========================================
- Hits 48393 38725 -9668
- Misses 14981 17600 +2619
+ Partials 3170 2718 -452
*This pull request uses carry forward flags. Click here to find out more.
|
/test-multicast-e2e |
2 similar comments
/test-multicast-e2e |
/test-multicast-e2e |
dc5d9aa
to
f5d8334
Compare
/test-multicast-e2e |
1 similar comment
/test-multicast-e2e |
f5d8334
to
59cc317
Compare
7fc2619
to
5003af1
Compare
8518edd
to
2d73d5d
Compare
e249a80
to
1dbefe2
Compare
2626238
to
b766d00
Compare
/test-multicast-e2e |
c3785c7
to
65ce623
Compare
30b1c69
to
3620719
Compare
func (c *MRouteClient) updateInboundMrouteStats() { | ||
for _, obj := range c.inboundRouteCache.List() { | ||
entry := obj.(*inboundMulticastRouteEntry) | ||
isDeleted, newEntry := c.updateMulticastRouteStatsEntry(&entry.multicastRouteEntry) |
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.
isDeleted, newEntry := c.updateMulticastRouteStatsEntry(&entry.multicastRouteEntry) | |
isStale, newEntry := c.updateMulticastRouteStatsEntry(&entry.multicastRouteEntry) |
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.
updated
func (c *MRouteClient) updateOutboundMrouteStats() { | ||
for _, obj := range c.outboundRouteCache.List() { | ||
entry := obj.(*outboundMulticastRouteEntry) | ||
isDeleted, newEntry := c.updateMulticastRouteStatsEntry(&entry.multicastRouteEntry) |
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
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.
updated
Grp [4]byte /* in_addr */ | ||
Pktcnt uint32 | ||
Bytecnt uint32 | ||
If uint32 |
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.
What is the field "If" meaning, iif or oif ?
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.
IIF. This generated field is not used in our code. According to the Linux source code, the name should be Wrong_if, which is assigned by the wrong_if field in mr_mfc https://github.com/torvalds/linux/blob/master/include/linux/mroute_base.h#L115-L160
pkg/agent/multicast/mcast_route.go
Outdated
// inboundMulticastRouteEntry encodes the inbound multicast routing entry. | ||
// It has extra field Iif to represent inbound interface VIF. |
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.
// It has extra field Iif to represent inbound interface VIF. | |
// It has extra field vif to represent inbound interface VIF. |
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.
updated
pkg/agent/multicast/mcast_route.go
Outdated
// outboundMulticastRouteEntry encodes the outbound multicast routing entry. | ||
// For example, | ||
// | ||
// type inboundMulticastRouteEntry struct { |
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.
// type inboundMulticastRouteEntry struct { | |
// type outboundMulticastRouteEntry struct { |
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.
updated
func TestUpdateOutboundMrouteStats(t *testing.T) { | ||
mRoute := newMockMulticastRouteClient(t) | ||
err := mRoute.initialize(t) | ||
assert.Nil(t, err) |
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.
use "require.NoError(t, err)" to ensure the succeeding logic can run as expected.
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.
updated
func TestUpdateInboundMrouteStats(t *testing.T) { | ||
mRoute := newMockMulticastRouteClient(t) | ||
err := mRoute.initialize(t) | ||
assert.Nil(t, err) |
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
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.
updated
mockMulticastSocket.EXPECT().DelMrouteEntry(net.ParseIP(m.source), net.ParseIP(m.group), uint16(0)).Times(1) | ||
} | ||
} | ||
mRoute.updateMrouteStats() |
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.
Would you also verify if the stale entry is finally deleted from the cache? Also add this verification in TestUpdateInboundMrouteStats
?
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.
updated
e41efa8
to
0be1bdd
Compare
/test-multicast-e2e |
2 similar comments
/test-multicast-e2e |
/test-multicast-e2e |
/test-flexible-ipam-e2e |
2 similar comments
/test-flexible-ipam-e2e |
/test-flexible-ipam-e2e |
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.
One comment, others LGTM.
BTW, don't forget to rebase your patch on main branch, and resolve candidate conflicts.
for i := 0; i < int(workerCount); i++ { | ||
go c.worker(stopCh) | ||
} | ||
<-stopCh | ||
c.socket.FlushMRoute() | ||
syscall.Close(c.socket.GetFD()) | ||
} | ||
|
||
func (c *MRouteClient) updateMulticastRouteStatsEntry(entry *multicastRouteEntry) (isStale bool, newEntry *multicastRouteEntry) { |
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.
I feel we can modify the parameter entry
to use the value instead of a pointer, since the struct is small and the function logic only reads the values but not modifies it. Then you don't need to get the pointer inside a for loop in the caller?
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.
updated
0be1bdd
to
872c8ab
Compare
Check the packet count difference every minute for each multicast route and remove the ones that have identical packet count in the past 10 minutes. Signed-off-by: ceclinux <src655@gmail.com>
872c8ab
to
1b29753
Compare
rebased |
/test-multicast-e2e |
2 similar comments
/test-multicast-e2e |
/test-multicast-e2e |
/test-flexible-ipam-e2e |
2 similar comments
/test-flexible-ipam-e2e |
/test-flexible-ipam-e2e |
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.
LGTM
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.
LGTM, thanks
/test-all |
/skip-conformance the test succeeded |
This commit removes the relevant stale multicast routes. When multicast sender Pods are deleted or stop sending multicast traffic in 10 minutes, the related multicast routes should be considered as stale and are removed with this commit. MRouted implements a similar stale routes cleanup mechanism in OpenBSD and NetBSD.
Periodically cleaning stale multicast routes would improve the readability of multicast routes, such as the readability of "ip mroute" output. Also, the memory consumption of Nodes could be slightly reduced(
running 28 multicast senders, each sending multicast traffic to 2000 multicast groups, around 16M Slab Unclaimable memory was consumed by 56000 multicast route entries, observed from Netdata).