@@ -800,7 +800,7 @@ impl PrimaryChannelState {
800
800
tx_spread_sent : bool ,
801
801
guest_link_down : bool ,
802
802
pending_link_action : Option < bool > ,
803
- packet_filter : u32 ,
803
+ packet_filter : Option < u32 > ,
804
804
) -> Result < Self , NetRestoreError > {
805
805
// Restore control messages.
806
806
let control_messages_len = control_messages. iter ( ) . map ( |msg| msg. data . len ( ) ) . sum ( ) ;
@@ -880,6 +880,8 @@ impl PrimaryChannelState {
880
880
PendingLinkAction :: Default
881
881
} ;
882
882
883
+ let packet_filter = packet_filter. unwrap_or ( rndisprot:: NPROTO_PACKET_FILTER ) ;
884
+
883
885
Ok ( Self {
884
886
guest_vf_state,
885
887
is_data_path_switched : None ,
@@ -1198,7 +1200,24 @@ impl VmbusDevice for Nic {
1198
1200
. adapter
1199
1201
. num_sub_channels_opened
1200
1202
. fetch_add ( 1 , Ordering :: SeqCst ) ;
1201
- let packet_filter = rndisprot:: NDIS_PACKET_TYPE_NONE ; // No traffic until guest sets filter.
1203
+
1204
+ let packet_filter = if channel_idx == 0 {
1205
+ // No rx traffic on primary channel until guest sets filter.
1206
+ rndisprot:: NDIS_PACKET_TYPE_NONE
1207
+ } else {
1208
+ // Subchannel inherits the packet filter of the primary channel.
1209
+ // Stop the primary worker task temporarily to safely access the state.
1210
+ let coordinator = self . coordinator . state_mut ( ) . unwrap ( ) ;
1211
+ coordinator. workers [ 0 ] . stop ( ) . await ;
1212
+ let packet_filter = coordinator. workers [ 0 ]
1213
+ . state ( )
1214
+ . unwrap ( )
1215
+ . channel
1216
+ . packet_filter ;
1217
+ coordinator. workers [ 0 ] . start ( ) ;
1218
+ packet_filter
1219
+ } ;
1220
+
1202
1221
let r = self . insert_worker ( channel_idx, open_request, state, true , packet_filter) ;
1203
1222
if channel_idx != 0
1204
1223
&& num_opened + 1 == self . coordinator . state_mut ( ) . unwrap ( ) . num_queues as usize
@@ -1828,7 +1847,7 @@ impl Nic {
1828
1847
tx_spread_sent : primary. tx_spread_sent ,
1829
1848
guest_link_down : !primary. guest_link_up ,
1830
1849
pending_link_action,
1831
- packet_filter : primary. packet_filter ,
1850
+ packet_filter : Some ( primary. packet_filter ) ,
1832
1851
} )
1833
1852
}
1834
1853
} ;
0 commit comments