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

login
register
mail settings
Submitter Jan Kiszka
Date June 7, 2011, 4:45 p.m.
Message ID <574a9f35e927e0dfd88161aa7da8c79e7e83ab46.1307465139.git.jan.kiszka@siemens.com>
Download mbox | patch
Permalink /patch/99310/
State New
Headers show

Comments

Jan Kiszka - June 7, 2011, 4:45 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

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;
         }