[3/4] slirp: Strictly associate DHCP/BOOTP and TFTP with virtual host

Submitted by Jan Kiszka on May 23, 2011, 2:48 p.m.

Details

Message ID d222da8b0cc39ebbffd85457ec0e7fed713425fa.1306162095.git.jan.kiszka@siemens.com
State New
Headers show

Commit Message

Jan Kiszka May 23, 2011, 2:48 p.m.
Instead of accepting every DHCP/BOOTP and TFTP packet, only invoke the
built-in servers if the target is the virtual host.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 slirp/udp.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/slirp/udp.c b/slirp/udp.c
index f1a9a10..cefd50b 100644
--- a/slirp/udp.c
+++ b/slirp/udp.c
@@ -120,15 +120,18 @@  udp_input(register struct mbuf *m, int iphlen)
         /*
          *  handle DHCP/BOOTP
          */
-        if (ntohs(uh->uh_dport) == BOOTP_SERVER) {
-            bootp_input(m);
-            goto bad;
-        }
+        if (ntohs(uh->uh_dport) == BOOTP_SERVER &&
+            (ip->ip_dst.s_addr == slirp->vhost_addr.s_addr ||
+             ip->ip_dst.s_addr == 0xffffffff)) {
+                bootp_input(m);
+                goto bad;
+            }
 
         /*
          *  handle TFTP
          */
-        if (ntohs(uh->uh_dport) == TFTP_SERVER) {
+        if (ntohs(uh->uh_dport) == TFTP_SERVER &&
+            ip->ip_dst.s_addr == slirp->vhost_addr.s_addr) {
             tftp_input(m);
             goto bad;
         }