Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ipvs: use the new dest addr family field

Use the new address family field cp->daf when printing
cp->daddr in logs or connection listing.

Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Alex Gartrell <agartrell@fb.com>
Signed-off-by: Simon Horman <horms@verge.net.au>

authored by

Julian Anastasov and committed by
Simon Horman
f18ae720 4d316f3f

+43 -16
+38 -11
net/netfilter/ipvs/ip_vs_conn.c
··· 27 27 28 28 #include <linux/interrupt.h> 29 29 #include <linux/in.h> 30 + #include <linux/inet.h> 30 31 #include <linux/net.h> 31 32 #include <linux/kernel.h> 32 33 #include <linux/module.h> ··· 77 76 #define CT_LOCKARRAY_BITS 5 78 77 #define CT_LOCKARRAY_SIZE (1<<CT_LOCKARRAY_BITS) 79 78 #define CT_LOCKARRAY_MASK (CT_LOCKARRAY_SIZE-1) 79 + 80 + /* We need an addrstrlen that works with or without v6 */ 81 + #ifdef CONFIG_IP_VS_IPV6 82 + #define IP_VS_ADDRSTRLEN INET6_ADDRSTRLEN 83 + #else 84 + #define IP_VS_ADDRSTRLEN (8+1) 85 + #endif 80 86 81 87 struct ip_vs_aligned_lock 82 88 { ··· 596 588 ip_vs_proto_name(cp->protocol), 597 589 IP_VS_DBG_ADDR(cp->af, &cp->caddr), ntohs(cp->cport), 598 590 IP_VS_DBG_ADDR(cp->af, &cp->vaddr), ntohs(cp->vport), 599 - IP_VS_DBG_ADDR(cp->af, &cp->daddr), ntohs(cp->dport), 591 + IP_VS_DBG_ADDR(cp->daf, &cp->daddr), ntohs(cp->dport), 600 592 ip_vs_fwd_tag(cp), cp->state, 601 593 cp->flags, atomic_read(&cp->refcnt), 602 594 atomic_read(&dest->refcnt)); ··· 693 685 ip_vs_proto_name(cp->protocol), 694 686 IP_VS_DBG_ADDR(cp->af, &cp->caddr), ntohs(cp->cport), 695 687 IP_VS_DBG_ADDR(cp->af, &cp->vaddr), ntohs(cp->vport), 696 - IP_VS_DBG_ADDR(cp->af, &cp->daddr), ntohs(cp->dport), 688 + IP_VS_DBG_ADDR(cp->daf, &cp->daddr), ntohs(cp->dport), 697 689 ip_vs_fwd_tag(cp), cp->state, 698 690 cp->flags, atomic_read(&cp->refcnt), 699 691 atomic_read(&dest->refcnt)); ··· 762 754 ntohs(ct->cport), 763 755 IP_VS_DBG_ADDR(ct->af, &ct->vaddr), 764 756 ntohs(ct->vport), 765 - IP_VS_DBG_ADDR(ct->af, &ct->daddr), 757 + IP_VS_DBG_ADDR(ct->daf, &ct->daddr), 766 758 ntohs(ct->dport)); 767 759 768 760 /* ··· 1059 1051 struct net *net = seq_file_net(seq); 1060 1052 char pe_data[IP_VS_PENAME_MAXLEN + IP_VS_PEDATA_MAXLEN + 3]; 1061 1053 size_t len = 0; 1054 + char dbuf[IP_VS_ADDRSTRLEN]; 1062 1055 1063 1056 if (!ip_vs_conn_net_eq(cp, net)) 1064 1057 return 0; ··· 1074 1065 pe_data[len] = '\0'; 1075 1066 1076 1067 #ifdef CONFIG_IP_VS_IPV6 1068 + if (cp->daf == AF_INET6) 1069 + snprintf(dbuf, sizeof(dbuf), "%pI6", &cp->daddr.in6); 1070 + else 1071 + #endif 1072 + snprintf(dbuf, sizeof(dbuf), "%08X", 1073 + ntohl(cp->daddr.ip)); 1074 + 1075 + #ifdef CONFIG_IP_VS_IPV6 1077 1076 if (cp->af == AF_INET6) 1078 1077 seq_printf(seq, "%-3s %pI6 %04X %pI6 %04X " 1079 - "%pI6 %04X %-11s %7lu%s\n", 1078 + "%s %04X %-11s %7lu%s\n", 1080 1079 ip_vs_proto_name(cp->protocol), 1081 1080 &cp->caddr.in6, ntohs(cp->cport), 1082 1081 &cp->vaddr.in6, ntohs(cp->vport), 1083 - &cp->daddr.in6, ntohs(cp->dport), 1082 + dbuf, ntohs(cp->dport), 1084 1083 ip_vs_state_name(cp->protocol, cp->state), 1085 1084 (cp->timer.expires-jiffies)/HZ, pe_data); 1086 1085 else 1087 1086 #endif 1088 1087 seq_printf(seq, 1089 1088 "%-3s %08X %04X %08X %04X" 1090 - " %08X %04X %-11s %7lu%s\n", 1089 + " %s %04X %-11s %7lu%s\n", 1091 1090 ip_vs_proto_name(cp->protocol), 1092 1091 ntohl(cp->caddr.ip), ntohs(cp->cport), 1093 1092 ntohl(cp->vaddr.ip), ntohs(cp->vport), 1094 - ntohl(cp->daddr.ip), ntohs(cp->dport), 1093 + dbuf, ntohs(cp->dport), 1095 1094 ip_vs_state_name(cp->protocol, cp->state), 1096 1095 (cp->timer.expires-jiffies)/HZ, pe_data); 1097 1096 } ··· 1137 1120 1138 1121 static int ip_vs_conn_sync_seq_show(struct seq_file *seq, void *v) 1139 1122 { 1123 + char dbuf[IP_VS_ADDRSTRLEN]; 1140 1124 1141 1125 if (v == SEQ_START_TOKEN) 1142 1126 seq_puts(seq, ··· 1150 1132 return 0; 1151 1133 1152 1134 #ifdef CONFIG_IP_VS_IPV6 1135 + if (cp->daf == AF_INET6) 1136 + snprintf(dbuf, sizeof(dbuf), "%pI6", &cp->daddr.in6); 1137 + else 1138 + #endif 1139 + snprintf(dbuf, sizeof(dbuf), "%08X", 1140 + ntohl(cp->daddr.ip)); 1141 + 1142 + #ifdef CONFIG_IP_VS_IPV6 1153 1143 if (cp->af == AF_INET6) 1154 - seq_printf(seq, "%-3s %pI6 %04X %pI6 %04X %pI6 %04X %-11s %-6s %7lu\n", 1144 + seq_printf(seq, "%-3s %pI6 %04X %pI6 %04X " 1145 + "%s %04X %-11s %-6s %7lu\n", 1155 1146 ip_vs_proto_name(cp->protocol), 1156 1147 &cp->caddr.in6, ntohs(cp->cport), 1157 1148 &cp->vaddr.in6, ntohs(cp->vport), 1158 - &cp->daddr.in6, ntohs(cp->dport), 1149 + dbuf, ntohs(cp->dport), 1159 1150 ip_vs_state_name(cp->protocol, cp->state), 1160 1151 ip_vs_origin_name(cp->flags), 1161 1152 (cp->timer.expires-jiffies)/HZ); ··· 1172 1145 #endif 1173 1146 seq_printf(seq, 1174 1147 "%-3s %08X %04X %08X %04X " 1175 - "%08X %04X %-11s %-6s %7lu\n", 1148 + "%s %04X %-11s %-6s %7lu\n", 1176 1149 ip_vs_proto_name(cp->protocol), 1177 1150 ntohl(cp->caddr.ip), ntohs(cp->cport), 1178 1151 ntohl(cp->vaddr.ip), ntohs(cp->vport), 1179 - ntohl(cp->daddr.ip), ntohs(cp->dport), 1152 + dbuf, ntohs(cp->dport), 1180 1153 ip_vs_state_name(cp->protocol, cp->state), 1181 1154 ip_vs_origin_name(cp->flags), 1182 1155 (cp->timer.expires-jiffies)/HZ);
+3 -3
net/netfilter/ipvs/ip_vs_core.c
··· 492 492 IP_VS_DBG_BUF(6, "Schedule fwd:%c c:%s:%u v:%s:%u " 493 493 "d:%s:%u conn->flags:%X conn->refcnt:%d\n", 494 494 ip_vs_fwd_tag(cp), 495 - IP_VS_DBG_ADDR(svc->af, &cp->caddr), ntohs(cp->cport), 496 - IP_VS_DBG_ADDR(svc->af, &cp->vaddr), ntohs(cp->vport), 497 - IP_VS_DBG_ADDR(svc->af, &cp->daddr), ntohs(cp->dport), 495 + IP_VS_DBG_ADDR(cp->af, &cp->caddr), ntohs(cp->cport), 496 + IP_VS_DBG_ADDR(cp->af, &cp->vaddr), ntohs(cp->vport), 497 + IP_VS_DBG_ADDR(cp->daf, &cp->daddr), ntohs(cp->dport), 498 498 cp->flags, atomic_read(&cp->refcnt)); 499 499 500 500 ip_vs_conn_stats(cp, svc);
+1 -1
net/netfilter/ipvs/ip_vs_proto_sctp.c
··· 432 432 pd->pp->name, 433 433 ((direction == IP_VS_DIR_OUTPUT) ? 434 434 "output " : "input "), 435 - IP_VS_DBG_ADDR(cp->af, &cp->daddr), 435 + IP_VS_DBG_ADDR(cp->daf, &cp->daddr), 436 436 ntohs(cp->dport), 437 437 IP_VS_DBG_ADDR(cp->af, &cp->caddr), 438 438 ntohs(cp->cport),
+1 -1
net/netfilter/ipvs/ip_vs_proto_tcp.c
··· 510 510 th->fin ? 'F' : '.', 511 511 th->ack ? 'A' : '.', 512 512 th->rst ? 'R' : '.', 513 - IP_VS_DBG_ADDR(cp->af, &cp->daddr), 513 + IP_VS_DBG_ADDR(cp->daf, &cp->daddr), 514 514 ntohs(cp->dport), 515 515 IP_VS_DBG_ADDR(cp->af, &cp->caddr), 516 516 ntohs(cp->cport),