From owner-p4-projects@FreeBSD.ORG Sat May 31 06:30:39 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 00DE537B404; Sat, 31 May 2003 06:30:38 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7B95937B401 for ; Sat, 31 May 2003 06:30:38 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 10E2343FAF for ; Sat, 31 May 2003 06:30:38 -0700 (PDT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h4VDUb0U090209 for ; Sat, 31 May 2003 06:30:37 -0700 (PDT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h4VDUa3o090206 for perforce@freebsd.org; Sat, 31 May 2003 06:30:36 -0700 (PDT) Date: Sat, 31 May 2003 06:30:36 -0700 (PDT) Message-Id: <200305311330.h4VDUa3o090206@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Subject: PERFORCE change 32166 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 May 2003 13:30:39 -0000 http://perforce.freebsd.org/chv.cgi?CH=32166 Change 32166 by rwatson@rwatson_tislabs on 2003/05/31 06:30:19 Introduce two new MAC entry points: void mac_reflect_mbuf_icmp(m); void mac_reflect_mbuf_tcp(m); These entry points are invoked for "in-place" label updates when a packet is responded to without hitting another object (a socket, for example) in the network stack, at the ICMP and TCP levels respectively. Two similar policy-level entry points: void mpo_reflect_mbuf_icmp(m, label); void mpo_reflect_mbuf_tcp(m, label); Identical except with explicit label arguments to avoid policies having to grub around for the label themselves. Note: this changes the mac_policy_conf structure, and hence requires a rebuild of all modules. Affected files ... .. //depot/projects/trustedbsd/mac/sys/kern/kern_mac.c#388 edit .. //depot/projects/trustedbsd/mac/sys/netinet/ip_icmp.c#20 edit .. //depot/projects/trustedbsd/mac/sys/netinet/tcp_subr.c#34 edit .. //depot/projects/trustedbsd/mac/sys/sys/mac.h#236 edit .. //depot/projects/trustedbsd/mac/sys/sys/mac_policy.h#188 edit Differences ... ==== //depot/projects/trustedbsd/mac/sys/kern/kern_mac.c#388 (text+ko) ==== @@ -2435,6 +2435,25 @@ } void +mac_reflect_mbuf_icmp(struct mbuf *m) +{ + struct label *label; + + label = mbuf_to_label(m); + + MAC_PERFORM(reflect_mbuf_icmp, m, label); +} +void +mac_reflect_mbuf_tcp(struct mbuf *m) +{ + struct label *label; + + label = mbuf_to_label(m); + + MAC_PERFORM(reflect_mbuf_tcp, m, label); +} + +void mac_update_ipq(struct mbuf *fragment, struct ipq *ipq) { struct label *label; ==== //depot/projects/trustedbsd/mac/sys/netinet/ip_icmp.c#20 (text+ko) ==== @@ -596,10 +596,6 @@ /* * Reflect the ip packet back to the source - * - * XXXMAC: Right now, the old label is inheritted. In practice, - * we'll need an explicit MAC call here to set an appropriate label - * (in place). */ static void icmp_reflect(m) @@ -652,6 +648,9 @@ goto done; } match: +#ifdef MAC + mac_reflect_mbuf_icmp(m); +#endif t = IA_SIN(ia)->sin_addr; ip->ip_src = t; ip->ip_ttl = ip_defttl; ==== //depot/projects/trustedbsd/mac/sys/netinet/tcp_subr.c#34 (text+ko) ==== @@ -488,10 +488,10 @@ mac_create_mbuf_from_socket(tp->t_inpcb->inp_socket, m); } else { /* - * XXXMAC: This will need to call a mac function that - * modifies the mbuf label in place for TCP datagrams - * not associated with a PCB. + * Packet is not associated with a socket, so possibly + * update the label in place. */ + mac_reflect_mbuf_tcp(m); } #endif nth->th_seq = htonl(seq); ==== //depot/projects/trustedbsd/mac/sys/sys/mac.h#236 (text+ko) ==== @@ -211,6 +211,8 @@ struct ifnet *ifnet, struct mbuf *newmbuf); void mac_create_mbuf_netlayer(struct mbuf *oldmbuf, struct mbuf *newmbuf); int mac_fragment_match(struct mbuf *fragment, struct ipq *ipq); +void mac_reflect_mbuf_icmp(struct mbuf *m); +void mac_reflect_mbuf_tcp(struct mbuf *m); void mac_update_ipq(struct mbuf *fragment, struct ipq *ipq); /* ==== //depot/projects/trustedbsd/mac/sys/sys/mac_policy.h#188 (text+ko) ==== @@ -235,6 +235,9 @@ int (*mpo_fragment_match)(struct mbuf *fragment, struct label *fragmentlabel, struct ipq *ipq, struct label *ipqlabel); + void (*mpo_reflect_mbuf_icmp)(struct mbuf *m, + struct label *mlabel); + void (*mpo_reflect_mbuf_tcp)(struct mbuf *m, struct label *mlabel); void (*mpo_relabel_ifnet)(struct ucred *cred, struct ifnet *ifnet, struct label *ifnetlabel, struct label *newlabel); void (*mpo_update_ipq)(struct mbuf *fragment,