in_pcbbind: Merge duplicated prison_replace_wildcards()
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 15 Mar 2014 12:43:58 +0000 (20:43 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 15 Mar 2014 12:45:10 +0000 (20:45 +0800)
sys/netinet/in_pcb.c

index 697d88a..82c8817 100644 (file)
@@ -418,19 +418,20 @@ in_pcbbind(struct inpcb *inp, struct sockaddr *nam, struct thread *td)
                }
                inp->inp_laddr = sin->sin_addr;
        }
+
+       jsin.sin_family = AF_INET;
+       jsin.sin_addr.s_addr = inp->inp_laddr.s_addr;
+       if (!prison_replace_wildcards(td, (struct sockaddr *)&jsin)) {
+               inp->inp_laddr.s_addr = INADDR_ANY;
+               error = EINVAL;
+               goto done;
+       }
+       inp->inp_laddr.s_addr = jsin.sin_addr.s_addr;
+
        if (lport == 0) {
                ushort first, last;
                int count;
 
-               jsin.sin_family = AF_INET;
-               jsin.sin_addr.s_addr = inp->inp_laddr.s_addr;
-               if (!prison_replace_wildcards(td, (struct sockaddr *)&jsin)) {
-                       inp->inp_laddr.s_addr = INADDR_ANY;
-                       error = EINVAL;
-                       goto done;
-               }
-               inp->inp_laddr.s_addr = jsin.sin_addr.s_addr;
-
                inp->inp_flags |= INP_ANONPORT;
 
                if (inp->inp_flags & INP_HIGHPORT) {
@@ -498,16 +499,6 @@ in_pcbbind(struct inpcb *inp, struct sockaddr *nam, struct thread *td)
        }
        inp->inp_lport = lport;
 
-       jsin.sin_family = AF_INET;
-       jsin.sin_addr.s_addr = inp->inp_laddr.s_addr;
-       if (!prison_replace_wildcards(td, (struct sockaddr*)&jsin)) {
-               inp->inp_laddr.s_addr = INADDR_ANY;
-               inp->inp_lport = 0;
-               error = EINVAL;
-               goto done;
-       }
-       inp->inp_laddr.s_addr = jsin.sin_addr.s_addr;
-
        if (in_pcbinsporthash(inp) != 0) {
                inp->inp_laddr.s_addr = INADDR_ANY;
                inp->inp_lport = 0;