]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/net/route.c
xnu-3789.70.16.tar.gz
[apple/xnu.git] / bsd / net / route.c
index 4e5dd5af797045e9148aa5ce7774f2e8bf0c0320..96633f83378c4b03623a9a65257cac16f236f50c 100644 (file)
@@ -699,7 +699,7 @@ sa_trim(struct sockaddr *sa, int skip)
  */
 struct sockaddr *
 rtm_scrub(int type, int idx, struct sockaddr *hint, struct sockaddr *sa,
-    void *buf, uint32_t buflen, kauth_cred_t *credp)
+    void *buf, uint32_t buflen, kauth_cred_t *credp, uint32_t rtm_hint_flags)
 {
        struct sockaddr_storage *ss = (struct sockaddr_storage *)buf;
        struct sockaddr *ret = sa;
@@ -770,8 +770,20 @@ rtm_scrub(int type, int idx, struct sockaddr *hint, struct sockaddr *sa,
                }
                break;
        }
+       case RTAX_GATEWAY: {
+               /*
+                * Break if the gateway is not AF_LINK type (indirect routes)
+                *
+                * Else, if is, check if it is resolved. If not yet resolved
+                * simply break else scrub the link layer address.
+                */
+               if ((sa->sa_family != AF_LINK) || (SDL(sa)->sdl_alen == 0))
+                       break;
+               /* fallthrough */
+       }
        case RTAX_IFP: {
-               if (sa->sa_family == AF_LINK && credp) {
+               if (sa->sa_family == AF_LINK && credp &&
+                   (rtm_hint_flags & RTMF_HIDE_LLADDR)) {
                        struct sockaddr_dl *sdl = SDL(buf);
                        const void *bytes;
                        size_t size;