diff options
author | Rumen G. Bogdanovski <rumen@voicecho.com> | 2007-11-20 00:52:42 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:54:21 -0500 |
commit | 7a4fbb1fa46e1a84c246e7bcd99bff45935bf114 (patch) | |
tree | 1aa51598889bc8a4b2130d96cdaca5f65cd27c6e /net/ipv4/ipvs | |
parent | c237899d1f8c5bfcfc9d6204052e0e065827ff75 (diff) |
[IPVS]: Flag synced connections and expose them in proc
This patch labels the sync-created connections with IP_VS_CONN_F_SYNC
flag and creates /proc/net/ip_vs_conn_sync to enable monitoring of the
origin of the connections, if they are local or created by the
synchronization.
Signed-off-by: Rumen G. Bogdanovski <rumen@voicecho.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/ipvs')
-rw-r--r-- | net/ipv4/ipvs/ip_vs_conn.c | 53 | ||||
-rw-r--r-- | net/ipv4/ipvs/ip_vs_sync.c | 2 |
2 files changed, 54 insertions, 1 deletions
diff --git a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c index a22cee43ed7c..45a642edb93b 100644 --- a/net/ipv4/ipvs/ip_vs_conn.c +++ b/net/ipv4/ipvs/ip_vs_conn.c | |||
@@ -781,6 +781,57 @@ static const struct file_operations ip_vs_conn_fops = { | |||
781 | .llseek = seq_lseek, | 781 | .llseek = seq_lseek, |
782 | .release = seq_release, | 782 | .release = seq_release, |
783 | }; | 783 | }; |
784 | |||
785 | static const char *ip_vs_origin_name(unsigned flags) | ||
786 | { | ||
787 | if (flags & IP_VS_CONN_F_SYNC) | ||
788 | return "SYNC"; | ||
789 | else | ||
790 | return "LOCAL"; | ||
791 | } | ||
792 | |||
793 | static int ip_vs_conn_sync_seq_show(struct seq_file *seq, void *v) | ||
794 | { | ||
795 | |||
796 | if (v == SEQ_START_TOKEN) | ||
797 | seq_puts(seq, | ||
798 | "Pro FromIP FPrt ToIP TPrt DestIP DPrt State Origin Expires\n"); | ||
799 | else { | ||
800 | const struct ip_vs_conn *cp = v; | ||
801 | |||
802 | seq_printf(seq, | ||
803 | "%-3s %08X %04X %08X %04X %08X %04X %-11s %-6s %7lu\n", | ||
804 | ip_vs_proto_name(cp->protocol), | ||
805 | ntohl(cp->caddr), ntohs(cp->cport), | ||
806 | ntohl(cp->vaddr), ntohs(cp->vport), | ||
807 | ntohl(cp->daddr), ntohs(cp->dport), | ||
808 | ip_vs_state_name(cp->protocol, cp->state), | ||
809 | ip_vs_origin_name(cp->flags), | ||
810 | (cp->timer.expires-jiffies)/HZ); | ||
811 | } | ||
812 | return 0; | ||
813 | } | ||
814 | |||
815 | static const struct seq_operations ip_vs_conn_sync_seq_ops = { | ||
816 | .start = ip_vs_conn_seq_start, | ||
817 | .next = ip_vs_conn_seq_next, | ||
818 | .stop = ip_vs_conn_seq_stop, | ||
819 | .show = ip_vs_conn_sync_seq_show, | ||
820 | }; | ||
821 | |||
822 | static int ip_vs_conn_sync_open(struct inode *inode, struct file *file) | ||
823 | { | ||
824 | return seq_open(file, &ip_vs_conn_sync_seq_ops); | ||
825 | } | ||
826 | |||
827 | static const struct file_operations ip_vs_conn_sync_fops = { | ||
828 | .owner = THIS_MODULE, | ||
829 | .open = ip_vs_conn_sync_open, | ||
830 | .read = seq_read, | ||
831 | .llseek = seq_lseek, | ||
832 | .release = seq_release, | ||
833 | }; | ||
834 | |||
784 | #endif | 835 | #endif |
785 | 836 | ||
786 | 837 | ||
@@ -940,6 +991,7 @@ int ip_vs_conn_init(void) | |||
940 | } | 991 | } |
941 | 992 | ||
942 | proc_net_fops_create(&init_net, "ip_vs_conn", 0, &ip_vs_conn_fops); | 993 | proc_net_fops_create(&init_net, "ip_vs_conn", 0, &ip_vs_conn_fops); |
994 | proc_net_fops_create(&init_net, "ip_vs_conn_sync", 0, &ip_vs_conn_sync_fops); | ||
943 | 995 | ||
944 | /* calculate the random value for connection hash */ | 996 | /* calculate the random value for connection hash */ |
945 | get_random_bytes(&ip_vs_conn_rnd, sizeof(ip_vs_conn_rnd)); | 997 | get_random_bytes(&ip_vs_conn_rnd, sizeof(ip_vs_conn_rnd)); |
@@ -956,5 +1008,6 @@ void ip_vs_conn_cleanup(void) | |||
956 | /* Release the empty cache */ | 1008 | /* Release the empty cache */ |
957 | kmem_cache_destroy(ip_vs_conn_cachep); | 1009 | kmem_cache_destroy(ip_vs_conn_cachep); |
958 | proc_net_remove(&init_net, "ip_vs_conn"); | 1010 | proc_net_remove(&init_net, "ip_vs_conn"); |
1011 | proc_net_remove(&init_net, "ip_vs_conn_sync"); | ||
959 | vfree(ip_vs_conn_tab); | 1012 | vfree(ip_vs_conn_tab); |
960 | } | 1013 | } |
diff --git a/net/ipv4/ipvs/ip_vs_sync.c b/net/ipv4/ipvs/ip_vs_sync.c index bd930efc18da..47b7f8f3ae79 100644 --- a/net/ipv4/ipvs/ip_vs_sync.c +++ b/net/ipv4/ipvs/ip_vs_sync.c | |||
@@ -308,7 +308,7 @@ static void ip_vs_process_message(const char *buffer, const size_t buflen) | |||
308 | unsigned flags; | 308 | unsigned flags; |
309 | 309 | ||
310 | s = (struct ip_vs_sync_conn *)p; | 310 | s = (struct ip_vs_sync_conn *)p; |
311 | flags = ntohs(s->flags); | 311 | flags = ntohs(s->flags) | IP_VS_CONN_F_SYNC; |
312 | if (!(flags & IP_VS_CONN_F_TEMPLATE)) | 312 | if (!(flags & IP_VS_CONN_F_TEMPLATE)) |
313 | cp = ip_vs_conn_in_get(s->protocol, | 313 | cp = ip_vs_conn_in_get(s->protocol, |
314 | s->caddr, s->cport, | 314 | s->caddr, s->cport, |