[Devel] [PATCH RH7 3/3] netfilter: rectify ebtlog inside CT

Dmitry Safonov dsafonov at virtuozzo.com
Wed Dec 21 00:48:35 PST 2016


Print ebtables LOG into VE's log buffer.

Cc: Kirill Tkhai <ktkhai at virtuozzo.com>
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 net/bridge/netfilter/ebt_log.c | 35 ++++++++++++++++-------------------
 1 file changed, 16 insertions(+), 19 deletions(-)

diff --git a/net/bridge/netfilter/ebt_log.c b/net/bridge/netfilter/ebt_log.c
index dc724cdfe76d..d13ef510fdc6 100644
--- a/net/bridge/netfilter/ebt_log.c
+++ b/net/bridge/netfilter/ebt_log.c
@@ -51,7 +51,7 @@ struct arppayload
 };
 
 static void
-print_ports(const struct sk_buff *skb, uint8_t protocol, int offset)
+print_ports(const struct sk_buff *skb, uint8_t protocol, int offset, struct ve_struct *ve)
 {
 	if (protocol == IPPROTO_TCP ||
 	    protocol == IPPROTO_UDP ||
@@ -64,10 +64,10 @@ print_ports(const struct sk_buff *skb, uint8_t protocol, int offset)
 		pptr = skb_header_pointer(skb, offset,
 					  sizeof(_ports), &_ports);
 		if (pptr == NULL) {
-			printk(" INCOMPLETE TCP/UDP header");
+			ve_log_printk(ve, " INCOMPLETE TCP/UDP header");
 			return;
 		}
-		printk(" SPT=%u DPT=%u", ntohs(pptr->src), ntohs(pptr->dst));
+		ve_log_printk(ve, " SPT=%u DPT=%u", ntohs(pptr->src), ntohs(pptr->dst));
 	}
 }
 
@@ -78,13 +78,10 @@ ebt_log_packet(struct net *net, u_int8_t pf, unsigned int hooknum,
 	       const char *prefix)
 {
 	unsigned int bitmask;
-
-	/* FIXME: Disabled from containers until syslog ns is supported */
-	if (!net_eq(net, &init_net))
-		return;
+	struct ve_struct *ve = net->owner_ve;
 
 	spin_lock_bh(&ebt_log_lock);
-	printk(KERN_SOH "%c%s IN=%s OUT=%s MAC source = %pM MAC dest = %pM proto = 0x%04x",
+	ve_log_printk(ve, KERN_SOH "%c%s IN=%s OUT=%s MAC source = %pM MAC dest = %pM proto = 0x%04x",
 	       '0' + loginfo->u.log.level, prefix,
 	       in ? in->name : "", out ? out->name : "",
 	       eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest,
@@ -102,12 +99,12 @@ ebt_log_packet(struct net *net, u_int8_t pf, unsigned int hooknum,
 
 		ih = skb_header_pointer(skb, 0, sizeof(_iph), &_iph);
 		if (ih == NULL) {
-			printk(" INCOMPLETE IP header");
+			ve_log_printk(ve, " INCOMPLETE IP header");
 			goto out;
 		}
-		printk(" IP SRC=%pI4 IP DST=%pI4, IP tos=0x%02X, IP proto=%d",
+		ve_log_printk(ve, " IP SRC=%pI4 IP DST=%pI4, IP tos=0x%02X, IP proto=%d",
 		       &ih->saddr, &ih->daddr, ih->tos, ih->protocol);
-		print_ports(skb, ih->protocol, ih->ihl*4);
+		print_ports(skb, ih->protocol, ih->ihl*4, ve);
 		goto out;
 	}
 
@@ -122,16 +119,16 @@ ebt_log_packet(struct net *net, u_int8_t pf, unsigned int hooknum,
 
 		ih = skb_header_pointer(skb, 0, sizeof(_iph), &_iph);
 		if (ih == NULL) {
-			printk(" INCOMPLETE IPv6 header");
+			ve_log_printk(ve, " INCOMPLETE IPv6 header");
 			goto out;
 		}
-		printk(" IPv6 SRC=%pI6 IPv6 DST=%pI6, IPv6 priority=0x%01X, Next Header=%d",
+		ve_log_printk(ve, " IPv6 SRC=%pI6 IPv6 DST=%pI6, IPv6 priority=0x%01X, Next Header=%d",
 		       &ih->saddr, &ih->daddr, ih->priority, ih->nexthdr);
 		nexthdr = ih->nexthdr;
 		offset_ph = ipv6_skip_exthdr(skb, sizeof(_iph), &nexthdr, &frag_off);
 		if (offset_ph == -1)
 			goto out;
-		print_ports(skb, nexthdr, offset_ph);
+		print_ports(skb, nexthdr, offset_ph, ve);
 		goto out;
 	}
 #endif
@@ -144,10 +141,10 @@ ebt_log_packet(struct net *net, u_int8_t pf, unsigned int hooknum,
 
 		ah = skb_header_pointer(skb, 0, sizeof(_arph), &_arph);
 		if (ah == NULL) {
-			printk(" INCOMPLETE ARP header");
+			ve_log_printk(ve, " INCOMPLETE ARP header");
 			goto out;
 		}
-		printk(" ARP HTYPE=%d, PTYPE=0x%04x, OPCODE=%d",
+		ve_log_printk(ve, " ARP HTYPE=%d, PTYPE=0x%04x, OPCODE=%d",
 		       ntohs(ah->ar_hrd), ntohs(ah->ar_pro),
 		       ntohs(ah->ar_op));
 
@@ -162,15 +159,15 @@ ebt_log_packet(struct net *net, u_int8_t pf, unsigned int hooknum,
 			ap = skb_header_pointer(skb, sizeof(_arph),
 						sizeof(_arpp), &_arpp);
 			if (ap == NULL) {
-				printk(" INCOMPLETE ARP payload");
+				ve_log_printk(ve, " INCOMPLETE ARP payload");
 				goto out;
 			}
-			printk(" ARP MAC SRC=%pM ARP IP SRC=%pI4 ARP MAC DST=%pM ARP IP DST=%pI4",
+			ve_log_printk(ve, " ARP MAC SRC=%pM ARP IP SRC=%pI4 ARP MAC DST=%pM ARP IP DST=%pI4",
 					ap->mac_src, ap->ip_src, ap->mac_dst, ap->ip_dst);
 		}
 	}
 out:
-	printk("\n");
+	ve_log_printk(ve, "\n");
 	spin_unlock_bh(&ebt_log_lock);
 
 }
-- 
2.11.0



More information about the Devel mailing list