chiark / gitweb /
server: reorg, messages
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 22 Aug 2021 14:59:03 +0000 (15:59 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 22 Aug 2021 14:59:03 +0000 (15:59 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
server/slocal.rs

index 152a570f16d12098486784869aad2f17242e03ee..62fb556829c459243c41448ea89dc98af4503d26 100644 (file)
@@ -36,43 +36,38 @@ pub async fn run(global: Arc<Global>,
           goodness -= goodness >> GOODNESS_SHIFT;
 
           // xxx should be process1
           goodness -= goodness >> GOODNESS_SHIFT;
 
           // xxx should be process1
-          match slip::processn(SlipNoConv, global.config.mtu, &data, |header|{
+          match process1(SlipNoConv, global.config.mtu, &data, |header|{
             let saddr = ip_packet_addr::<false>(header)?;
             let daddr = ip_packet_addr::<true>(header)?;
             Ok((saddr,daddr))
             let saddr = ip_packet_addr::<false>(header)?;
             let daddr = ip_packet_addr::<true>(header)?;
             Ok((saddr,daddr))
-          }, |(data, (saddr, daddr))| {
-            let global = &global;
-            let may_route = &may_route;
-            async move {
-              if ! global.config.vnetwork.iter().any(|n| n.contains(&saddr)) {
-                // pretent as if this came from route
-                trace!(
-                  target: "hippotatd",
- "discard to={:?} came=ipif user=local from-outside-vnets-={:?}",
-                  daddr, saddr);
-                return Ok(())
-              }
-
-              route_packet(
-                &global, "ipif", None,
-                data, daddr, may_route.clone()
-              ).await;
+          }) {
+            Err(PE::Empty) => { },
 
 
-              Ok(())
-            }
-          }, |pe| Ok(match pe {
-            PE::Empty => { },
-            other => throw!(other),
-          })).await {
-            Ok(()) => goodness += 1,
-            Err(e) => {
+            Err(pe) => {
               goodness -= 1;
               error!("[good={}] invalid data from local tx ipif {}",
               goodness -= 1;
               error!("[good={}] invalid data from local tx ipif {}",
-                     goodness, e);
+                     goodness, pe);
               if goodness < GOODNESS_MIN {
                 throw!(anyhow!("too many bad packets, too few good ones!"))
               }
             },
               if goodness < GOODNESS_MIN {
                 throw!(anyhow!("too many bad packets, too few good ones!"))
               }
             },
+
+            Ok((ref data, (ref saddr, ref daddr)))
+            if ! global.config.vnetwork.iter().any(|n| n.contains(saddr)) => {
+              // pretent as if this came from route
+              trace!(
+                target: "hippotatd",
+ "discard to={:?} came=ipif user=local len={} outside-vnets: from={:?}",
+                daddr, saddr, data.len());
+            },
+
+            Ok((data, (saddr, daddr))) => {
+              goodness += 1;
+              route_packet(
+                &global, "ipif", None,
+                data, daddr, may_route.clone()
+              ).await;
+            }
           }
         },
       }
           }
         },
       }