Drop packet if destination is unspecified (0.0.0.0/0) (#8321)
This commit is contained in:
		| @@ -1323,20 +1323,24 @@ impl ClusterInfo { | ||||
|             .into_iter() | ||||
|             .zip(addrs.into_iter()) | ||||
|             .for_each(|(response, from_addr)| { | ||||
|                 let len = response.len(); | ||||
|                 trace!("get updates since response {}", len); | ||||
|                 inc_new_counter_debug!("cluster_info-pull_request-rsp", len); | ||||
|                 Self::split_gossip_messages(response) | ||||
|                     .into_iter() | ||||
|                     .for_each(|payload| { | ||||
|                         let protocol = Protocol::PullResponse(self_id, payload); | ||||
|                         // The remote node may not know its public IP:PORT. Instead of responding to the caller's | ||||
|                         // gossip addr, respond to the origin addr. The last origin addr is picked from the list of | ||||
|                         // addrs. | ||||
|                         packets | ||||
|                             .packets | ||||
|                             .push(Packet::from_data(&from_addr, protocol)) | ||||
|                     }) | ||||
|                 if !from_addr.ip().is_unspecified() && from_addr.port() != 0 { | ||||
|                     let len = response.len(); | ||||
|                     trace!("get updates since response {}", len); | ||||
|                     inc_new_counter_debug!("cluster_info-pull_request-rsp", len); | ||||
|                     Self::split_gossip_messages(response) | ||||
|                         .into_iter() | ||||
|                         .for_each(|payload| { | ||||
|                             let protocol = Protocol::PullResponse(self_id, payload); | ||||
|                             // The remote node may not know its public IP:PORT. Instead of responding to the caller's | ||||
|                             // gossip addr, respond to the origin addr. The last origin addr is picked from the list of | ||||
|                             // addrs. | ||||
|                             packets | ||||
|                                 .packets | ||||
|                                 .push(Packet::from_data(&from_addr, protocol)) | ||||
|                         }) | ||||
|                 } else { | ||||
|                     trace!("Dropping Gossip pull response, as destination is unknown"); | ||||
|                 } | ||||
|             }); | ||||
|         if packets.is_empty() { | ||||
|             return None; | ||||
| @@ -1413,8 +1417,12 @@ impl ClusterInfo { | ||||
|             let pushes: Vec<_> = me.write().unwrap().new_push_requests(); | ||||
|             inc_new_counter_debug!("cluster_info-push_message-pushes", pushes.len()); | ||||
|             pushes.into_iter().for_each(|(remote_gossip_addr, req)| { | ||||
|                 let p = Packet::from_data(&remote_gossip_addr, &req); | ||||
|                 packets.packets.push(p); | ||||
|                 if !remote_gossip_addr.ip().is_unspecified() && remote_gossip_addr.port() != 0 { | ||||
|                     let p = Packet::from_data(&remote_gossip_addr, &req); | ||||
|                     packets.packets.push(p); | ||||
|                 } else { | ||||
|                     trace!("Dropping Gossip push response, as destination is unknown"); | ||||
|                 } | ||||
|             }); | ||||
|             Some(packets) | ||||
|         } else { | ||||
|   | ||||
| @@ -85,8 +85,12 @@ pub fn to_packets_with_destination<T: Serialize>( | ||||
|     ); | ||||
|     out.packets.resize(dests_and_data.len(), Packet::default()); | ||||
|     for (dest_and_data, o) in dests_and_data.iter().zip(out.packets.iter_mut()) { | ||||
|         if let Err(e) = Packet::populate_packet(o, Some(&dest_and_data.0), &dest_and_data.1) { | ||||
|             error!("Couldn't write to packet {:?}. Data skipped.", e); | ||||
|         if !dest_and_data.0.ip().is_unspecified() && dest_and_data.0.port() != 0 { | ||||
|             if let Err(e) = Packet::populate_packet(o, Some(&dest_and_data.0), &dest_and_data.1) { | ||||
|                 error!("Couldn't write to packet {:?}. Data skipped.", e); | ||||
|             } | ||||
|         } else { | ||||
|             trace!("Dropping packet, as destination is unknown"); | ||||
|         } | ||||
|     } | ||||
|     out | ||||
|   | ||||
		Reference in New Issue
	
	Block a user