Parcourir la source

[2902] Do not swap local and remote HW address when sending response.

Marcin Siodelski il y a 12 ans
Parent
commit
8f4d5d803a
2 fichiers modifiés avec 5 ajouts et 5 suppressions
  1. 3 3
      src/bin/dhcp4/dhcp4_srv.cc
  2. 2 2
      src/bin/dhcp4/tests/dhcp4_srv_unittest.cc

+ 3 - 3
src/bin/dhcp4/dhcp4_srv.cc

@@ -375,12 +375,12 @@ Dhcpv4Srv::copyDefaultFields(const Pkt4Ptr& question, Pkt4Ptr& answer) {
     // If src/dest HW addresses are used by the packet filtering class
     // we need to copy them as well.
     HWAddrPtr src_hw_addr = question->getLocalHWAddr();
-    HWAddrPtr dst_hw_addr = question->getRemoteHWAddr();
     if (src_hw_addr) {
-        answer->setRemoteHWAddr(src_hw_addr);
+        answer->setLocalHWAddr(src_hw_addr);
     }
+    HWAddrPtr dst_hw_addr = question->getRemoteHWAddr();
     if (dst_hw_addr) {
-        answer->setLocalHWAddr(dst_hw_addr);
+        answer->setRemoteHWAddr(dst_hw_addr);
     }
 }
 

+ 2 - 2
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc

@@ -176,8 +176,8 @@ public:
         // When processing an incoming packet the remote address
         // is copied as a src address, and the source address is
         // copied as a remote address to the response.
-        EXPECT_TRUE(q->getLocalHWAddr() == a->getRemoteHWAddr());
-        EXPECT_TRUE(q->getRemoteHWAddr() == a->getLocalHWAddr());
+        EXPECT_TRUE(q->getLocalHWAddr() == a->getLocalHWAddr());
+        EXPECT_TRUE(q->getRemoteHWAddr() == a->getRemoteHWAddr());
 
         // Check that bare minimum of required options are there.
         // We don't check options requested by a client. Those