diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2014-11-19 13:02:53 -0500 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-11-19 13:02:53 -0500 |
| commit | 8ce74dd6057832618957fc2cbd38fa959c3a0a6c (patch) | |
| tree | af3bede951087ebc58988ad073182a85bf899e27 | |
| parent | 78d28e651f97866d608d9b41f8ad291e65d47dd5 (diff) | |
| parent | 9761536e1d9e9e1f325fb04d4ad46b15a39eb94a (diff) | |
Merge tag 'trace-seq-file-cleanup' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace into for-next
Pull the beginning of seq_file cleanup from Steven:
"I'm looking to clean up the seq_file code and to eventually merge the
trace_seq code with seq_file as well, since they basically do the same thing.
Part of this process is to remove the return code of seq_printf() and friends
as they are rather inconsistent. It is better to use the new function
seq_has_overflowed() if you want to stop processing when the buffer
is full. Note, if the buffer is full, the seq_file code will throw away
the contents, allocate a bigger buffer, and then call your code again
to fill in the data. The only thing that breaking out of the function
early does is to save a little time which is probably never noticed.
I started with patches from Joe Perches and modified them as well.
There's many more places that need to be updated before we can convert
seq_printf() and friends to return void. But this patch set introduces
the seq_has_overflowed() and does some initial updates."
38 files changed, 410 insertions, 437 deletions
diff --git a/Documentation/filesystems/debugfs.txt b/Documentation/filesystems/debugfs.txt index 3a863f692728..88ab81c79109 100644 --- a/Documentation/filesystems/debugfs.txt +++ b/Documentation/filesystems/debugfs.txt | |||
| @@ -140,7 +140,7 @@ file. | |||
| 140 | struct dentry *parent, | 140 | struct dentry *parent, |
| 141 | struct debugfs_regset32 *regset); | 141 | struct debugfs_regset32 *regset); |
| 142 | 142 | ||
| 143 | int debugfs_print_regs32(struct seq_file *s, struct debugfs_reg32 *regs, | 143 | void debugfs_print_regs32(struct seq_file *s, struct debugfs_reg32 *regs, |
| 144 | int nregs, void __iomem *base, char *prefix); | 144 | int nregs, void __iomem *base, char *prefix); |
| 145 | 145 | ||
| 146 | The "base" argument may be 0, but you may want to build the reg32 array | 146 | The "base" argument may be 0, but you may want to build the reg32 array |
diff --git a/Documentation/filesystems/seq_file.txt b/Documentation/filesystems/seq_file.txt index 8ea3e90ace07..b797ed38de46 100644 --- a/Documentation/filesystems/seq_file.txt +++ b/Documentation/filesystems/seq_file.txt | |||
| @@ -180,23 +180,19 @@ output must be passed to the seq_file code. Some utility functions have | |||
| 180 | been defined which make this task easy. | 180 | been defined which make this task easy. |
| 181 | 181 | ||
| 182 | Most code will simply use seq_printf(), which works pretty much like | 182 | Most code will simply use seq_printf(), which works pretty much like |
| 183 | printk(), but which requires the seq_file pointer as an argument. It is | 183 | printk(), but which requires the seq_file pointer as an argument. |
| 184 | common to ignore the return value from seq_printf(), but a function | ||
| 185 | producing complicated output may want to check that value and quit if | ||
| 186 | something non-zero is returned; an error return means that the seq_file | ||
| 187 | buffer has been filled and further output will be discarded. | ||
| 188 | 184 | ||
| 189 | For straight character output, the following functions may be used: | 185 | For straight character output, the following functions may be used: |
| 190 | 186 | ||
| 191 | int seq_putc(struct seq_file *m, char c); | 187 | seq_putc(struct seq_file *m, char c); |
| 192 | int seq_puts(struct seq_file *m, const char *s); | 188 | seq_puts(struct seq_file *m, const char *s); |
| 193 | int seq_escape(struct seq_file *m, const char *s, const char *esc); | 189 | seq_escape(struct seq_file *m, const char *s, const char *esc); |
| 194 | 190 | ||
| 195 | The first two output a single character and a string, just like one would | 191 | The first two output a single character and a string, just like one would |
| 196 | expect. seq_escape() is like seq_puts(), except that any character in s | 192 | expect. seq_escape() is like seq_puts(), except that any character in s |
| 197 | which is in the string esc will be represented in octal form in the output. | 193 | which is in the string esc will be represented in octal form in the output. |
| 198 | 194 | ||
| 199 | There is also a pair of functions for printing filenames: | 195 | There are also a pair of functions for printing filenames: |
| 200 | 196 | ||
| 201 | int seq_path(struct seq_file *m, struct path *path, char *esc); | 197 | int seq_path(struct seq_file *m, struct path *path, char *esc); |
| 202 | int seq_path_root(struct seq_file *m, struct path *path, | 198 | int seq_path_root(struct seq_file *m, struct path *path, |
| @@ -209,6 +205,14 @@ root is desired, it can be used with seq_path_root(). Note that, if it | |||
| 209 | turns out that path cannot be reached from root, the value of root will be | 205 | turns out that path cannot be reached from root, the value of root will be |
| 210 | changed in seq_file_root() to a root which *does* work. | 206 | changed in seq_file_root() to a root which *does* work. |
| 211 | 207 | ||
| 208 | A function producing complicated output may want to check | ||
| 209 | bool seq_has_overflowed(struct seq_file *m); | ||
| 210 | and avoid further seq_<output> calls if true is returned. | ||
| 211 | |||
| 212 | A true return from seq_has_overflowed means that the seq_file buffer will | ||
| 213 | be discarded and the seq_show function will attempt to allocate a larger | ||
| 214 | buffer and retry printing. | ||
| 215 | |||
| 212 | 216 | ||
| 213 | Making it all work | 217 | Making it all work |
| 214 | 218 | ||
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index 20bf204426ca..43ce0507ee25 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt | |||
| @@ -835,7 +835,7 @@ struct file_operations { | |||
| 835 | ssize_t (*splice_read)(struct file *, struct pipe_inode_info *, size_t, unsigned int); | 835 | ssize_t (*splice_read)(struct file *, struct pipe_inode_info *, size_t, unsigned int); |
| 836 | int (*setlease)(struct file *, long arg, struct file_lock **, void **); | 836 | int (*setlease)(struct file *, long arg, struct file_lock **, void **); |
| 837 | long (*fallocate)(struct file *, int mode, loff_t offset, loff_t len); | 837 | long (*fallocate)(struct file *, int mode, loff_t offset, loff_t len); |
| 838 | int (*show_fdinfo)(struct seq_file *m, struct file *f); | 838 | void (*show_fdinfo)(struct seq_file *m, struct file *f); |
| 839 | }; | 839 | }; |
| 840 | 840 | ||
| 841 | Again, all methods are called without any locks being held, unless | 841 | Again, all methods are called without any locks being held, unless |
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 186ce541c657..a3420e091689 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c | |||
| @@ -2209,7 +2209,7 @@ static int tun_chr_close(struct inode *inode, struct file *file) | |||
| 2209 | } | 2209 | } |
| 2210 | 2210 | ||
| 2211 | #ifdef CONFIG_PROC_FS | 2211 | #ifdef CONFIG_PROC_FS |
| 2212 | static int tun_chr_show_fdinfo(struct seq_file *m, struct file *f) | 2212 | static void tun_chr_show_fdinfo(struct seq_file *m, struct file *f) |
| 2213 | { | 2213 | { |
| 2214 | struct tun_struct *tun; | 2214 | struct tun_struct *tun; |
| 2215 | struct ifreq ifr; | 2215 | struct ifreq ifr; |
| @@ -2225,7 +2225,7 @@ static int tun_chr_show_fdinfo(struct seq_file *m, struct file *f) | |||
| 2225 | if (tun) | 2225 | if (tun) |
| 2226 | tun_put(tun); | 2226 | tun_put(tun); |
| 2227 | 2227 | ||
| 2228 | return seq_printf(m, "iff:\t%s\n", ifr.ifr_name); | 2228 | seq_printf(m, "iff:\t%s\n", ifr.ifr_name); |
| 2229 | } | 2229 | } |
| 2230 | #endif | 2230 | #endif |
| 2231 | 2231 | ||
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index 76c08c2beb2f..8e0f2f410189 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c | |||
| @@ -692,18 +692,19 @@ EXPORT_SYMBOL_GPL(debugfs_create_u32_array); | |||
| 692 | * because some peripherals have several blocks of identical registers, | 692 | * because some peripherals have several blocks of identical registers, |
| 693 | * for example configuration of dma channels | 693 | * for example configuration of dma channels |
| 694 | */ | 694 | */ |
| 695 | int debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs, | 695 | void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs, |
| 696 | int nregs, void __iomem *base, char *prefix) | 696 | int nregs, void __iomem *base, char *prefix) |
| 697 | { | 697 | { |
| 698 | int i, ret = 0; | 698 | int i; |
| 699 | 699 | ||
| 700 | for (i = 0; i < nregs; i++, regs++) { | 700 | for (i = 0; i < nregs; i++, regs++) { |
| 701 | if (prefix) | 701 | if (prefix) |
| 702 | ret += seq_printf(s, "%s", prefix); | 702 | seq_printf(s, "%s", prefix); |
| 703 | ret += seq_printf(s, "%s = 0x%08x\n", regs->name, | 703 | seq_printf(s, "%s = 0x%08x\n", regs->name, |
| 704 | readl(base + regs->offset)); | 704 | readl(base + regs->offset)); |
| 705 | if (seq_has_overflowed(s)) | ||
| 706 | break; | ||
| 705 | } | 707 | } |
| 706 | return ret; | ||
| 707 | } | 708 | } |
| 708 | EXPORT_SYMBOL_GPL(debugfs_print_regs32); | 709 | EXPORT_SYMBOL_GPL(debugfs_print_regs32); |
| 709 | 710 | ||
diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c index 1323c568e362..eea64912c9c0 100644 --- a/fs/dlm/debug_fs.c +++ b/fs/dlm/debug_fs.c | |||
| @@ -48,8 +48,8 @@ static char *print_lockmode(int mode) | |||
| 48 | } | 48 | } |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | static int print_format1_lock(struct seq_file *s, struct dlm_lkb *lkb, | 51 | static void print_format1_lock(struct seq_file *s, struct dlm_lkb *lkb, |
| 52 | struct dlm_rsb *res) | 52 | struct dlm_rsb *res) |
| 53 | { | 53 | { |
| 54 | seq_printf(s, "%08x %s", lkb->lkb_id, print_lockmode(lkb->lkb_grmode)); | 54 | seq_printf(s, "%08x %s", lkb->lkb_id, print_lockmode(lkb->lkb_grmode)); |
| 55 | 55 | ||
| @@ -68,21 +68,17 @@ static int print_format1_lock(struct seq_file *s, struct dlm_lkb *lkb, | |||
| 68 | if (lkb->lkb_wait_type) | 68 | if (lkb->lkb_wait_type) |
| 69 | seq_printf(s, " wait_type: %d", lkb->lkb_wait_type); | 69 | seq_printf(s, " wait_type: %d", lkb->lkb_wait_type); |
| 70 | 70 | ||
| 71 | return seq_puts(s, "\n"); | 71 | seq_puts(s, "\n"); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | static int print_format1(struct dlm_rsb *res, struct seq_file *s) | 74 | static void print_format1(struct dlm_rsb *res, struct seq_file *s) |
| 75 | { | 75 | { |
| 76 | struct dlm_lkb *lkb; | 76 | struct dlm_lkb *lkb; |
| 77 | int i, lvblen = res->res_ls->ls_lvblen, recover_list, root_list; | 77 | int i, lvblen = res->res_ls->ls_lvblen, recover_list, root_list; |
| 78 | int rv; | ||
| 79 | 78 | ||
| 80 | lock_rsb(res); | 79 | lock_rsb(res); |
| 81 | 80 | ||
| 82 | rv = seq_printf(s, "\nResource %p Name (len=%d) \"", | 81 | seq_printf(s, "\nResource %p Name (len=%d) \"", res, res->res_length); |
| 83 | res, res->res_length); | ||
| 84 | if (rv) | ||
| 85 | goto out; | ||
| 86 | 82 | ||
| 87 | for (i = 0; i < res->res_length; i++) { | 83 | for (i = 0; i < res->res_length; i++) { |
| 88 | if (isprint(res->res_name[i])) | 84 | if (isprint(res->res_name[i])) |
| @@ -92,17 +88,16 @@ static int print_format1(struct dlm_rsb *res, struct seq_file *s) | |||
| 92 | } | 88 | } |
| 93 | 89 | ||
| 94 | if (res->res_nodeid > 0) | 90 | if (res->res_nodeid > 0) |
| 95 | rv = seq_printf(s, "\"\nLocal Copy, Master is node %d\n", | 91 | seq_printf(s, "\"\nLocal Copy, Master is node %d\n", |
| 96 | res->res_nodeid); | 92 | res->res_nodeid); |
| 97 | else if (res->res_nodeid == 0) | 93 | else if (res->res_nodeid == 0) |
| 98 | rv = seq_puts(s, "\"\nMaster Copy\n"); | 94 | seq_puts(s, "\"\nMaster Copy\n"); |
| 99 | else if (res->res_nodeid == -1) | 95 | else if (res->res_nodeid == -1) |
| 100 | rv = seq_printf(s, "\"\nLooking up master (lkid %x)\n", | 96 | seq_printf(s, "\"\nLooking up master (lkid %x)\n", |
| 101 | res->res_first_lkid); | 97 | res->res_first_lkid); |
| 102 | else | 98 | else |
| 103 | rv = seq_printf(s, "\"\nInvalid master %d\n", | 99 | seq_printf(s, "\"\nInvalid master %d\n", res->res_nodeid); |
| 104 | res->res_nodeid); | 100 | if (seq_has_overflowed(s)) |
| 105 | if (rv) | ||
| 106 | goto out; | 101 | goto out; |
| 107 | 102 | ||
| 108 | /* Print the LVB: */ | 103 | /* Print the LVB: */ |
| @@ -116,8 +111,8 @@ static int print_format1(struct dlm_rsb *res, struct seq_file *s) | |||
| 116 | } | 111 | } |
| 117 | if (rsb_flag(res, RSB_VALNOTVALID)) | 112 | if (rsb_flag(res, RSB_VALNOTVALID)) |
| 118 | seq_puts(s, " (INVALID)"); | 113 | seq_puts(s, " (INVALID)"); |
| 119 | rv = seq_puts(s, "\n"); | 114 | seq_puts(s, "\n"); |
| 120 | if (rv) | 115 | if (seq_has_overflowed(s)) |
| 121 | goto out; | 116 | goto out; |
| 122 | } | 117 | } |
| 123 | 118 | ||
| @@ -125,32 +120,30 @@ static int print_format1(struct dlm_rsb *res, struct seq_file *s) | |||
| 125 | recover_list = !list_empty(&res->res_recover_list); | 120 | recover_list = !list_empty(&res->res_recover_list); |
| 126 | 121 | ||
| 127 | if (root_list || recover_list) { | 122 | if (root_list || recover_list) { |
| 128 | rv = seq_printf(s, "Recovery: root %d recover %d flags %lx " | 123 | seq_printf(s, "Recovery: root %d recover %d flags %lx count %d\n", |
| 129 | "count %d\n", root_list, recover_list, | 124 | root_list, recover_list, |
| 130 | res->res_flags, res->res_recover_locks_count); | 125 | res->res_flags, res->res_recover_locks_count); |
| 131 | if (rv) | ||
| 132 | goto out; | ||
| 133 | } | 126 | } |
| 134 | 127 | ||
| 135 | /* Print the locks attached to this resource */ | 128 | /* Print the locks attached to this resource */ |
| 136 | seq_puts(s, "Granted Queue\n"); | 129 | seq_puts(s, "Granted Queue\n"); |
| 137 | list_for_each_entry(lkb, &res->res_grantqueue, lkb_statequeue) { | 130 | list_for_each_entry(lkb, &res->res_grantqueue, lkb_statequeue) { |
| 138 | rv = print_format1_lock(s, lkb, res); | 131 | print_format1_lock(s, lkb, res); |
| 139 | if (rv) | 132 | if (seq_has_overflowed(s)) |
| 140 | goto out; | 133 | goto out; |
| 141 | } | 134 | } |
| 142 | 135 | ||
| 143 | seq_puts(s, "Conversion Queue\n"); | 136 | seq_puts(s, "Conversion Queue\n"); |
| 144 | list_for_each_entry(lkb, &res->res_convertqueue, lkb_statequeue) { | 137 | list_for_each_entry(lkb, &res->res_convertqueue, lkb_statequeue) { |
| 145 | rv = print_format1_lock(s, lkb, res); | 138 | print_format1_lock(s, lkb, res); |
| 146 | if (rv) | 139 | if (seq_has_overflowed(s)) |
| 147 | goto out; | 140 | goto out; |
| 148 | } | 141 | } |
| 149 | 142 | ||
| 150 | seq_puts(s, "Waiting Queue\n"); | 143 | seq_puts(s, "Waiting Queue\n"); |
| 151 | list_for_each_entry(lkb, &res->res_waitqueue, lkb_statequeue) { | 144 | list_for_each_entry(lkb, &res->res_waitqueue, lkb_statequeue) { |
| 152 | rv = print_format1_lock(s, lkb, res); | 145 | print_format1_lock(s, lkb, res); |
| 153 | if (rv) | 146 | if (seq_has_overflowed(s)) |
| 154 | goto out; | 147 | goto out; |
| 155 | } | 148 | } |
| 156 | 149 | ||
| @@ -159,23 +152,23 @@ static int print_format1(struct dlm_rsb *res, struct seq_file *s) | |||
| 159 | 152 | ||
| 160 | seq_puts(s, "Lookup Queue\n"); | 153 | seq_puts(s, "Lookup Queue\n"); |
| 161 | list_for_each_entry(lkb, &res->res_lookup, lkb_rsb_lookup) { | 154 | list_for_each_entry(lkb, &res->res_lookup, lkb_rsb_lookup) { |
| 162 | rv = seq_printf(s, "%08x %s", lkb->lkb_id, | 155 | seq_printf(s, "%08x %s", |
| 163 | print_lockmode(lkb->lkb_rqmode)); | 156 | lkb->lkb_id, print_lockmode(lkb->lkb_rqmode)); |
| 164 | if (lkb->lkb_wait_type) | 157 | if (lkb->lkb_wait_type) |
| 165 | seq_printf(s, " wait_type: %d", lkb->lkb_wait_type); | 158 | seq_printf(s, " wait_type: %d", lkb->lkb_wait_type); |
| 166 | rv = seq_puts(s, "\n"); | 159 | seq_puts(s, "\n"); |
| 160 | if (seq_has_overflowed(s)) | ||
| 161 | goto out; | ||
| 167 | } | 162 | } |
| 168 | out: | 163 | out: |
| 169 | unlock_rsb(res); | 164 | unlock_rsb(res); |
| 170 | return rv; | ||
| 171 | } | 165 | } |
| 172 | 166 | ||
| 173 | static int print_format2_lock(struct seq_file *s, struct dlm_lkb *lkb, | 167 | static void print_format2_lock(struct seq_file *s, struct dlm_lkb *lkb, |
| 174 | struct dlm_rsb *r) | 168 | struct dlm_rsb *r) |
| 175 | { | 169 | { |
| 176 | u64 xid = 0; | 170 | u64 xid = 0; |
| 177 | u64 us; | 171 | u64 us; |
| 178 | int rv; | ||
| 179 | 172 | ||
| 180 | if (lkb->lkb_flags & DLM_IFL_USER) { | 173 | if (lkb->lkb_flags & DLM_IFL_USER) { |
| 181 | if (lkb->lkb_ua) | 174 | if (lkb->lkb_ua) |
| @@ -188,103 +181,97 @@ static int print_format2_lock(struct seq_file *s, struct dlm_lkb *lkb, | |||
| 188 | /* id nodeid remid pid xid exflags flags sts grmode rqmode time_us | 181 | /* id nodeid remid pid xid exflags flags sts grmode rqmode time_us |
| 189 | r_nodeid r_len r_name */ | 182 | r_nodeid r_len r_name */ |
| 190 | 183 | ||
| 191 | rv = seq_printf(s, "%x %d %x %u %llu %x %x %d %d %d %llu %u %d \"%s\"\n", | 184 | seq_printf(s, "%x %d %x %u %llu %x %x %d %d %d %llu %u %d \"%s\"\n", |
| 192 | lkb->lkb_id, | 185 | lkb->lkb_id, |
| 193 | lkb->lkb_nodeid, | 186 | lkb->lkb_nodeid, |
| 194 | lkb->lkb_remid, | 187 | lkb->lkb_remid, |
| 195 | lkb->lkb_ownpid, | 188 | lkb->lkb_ownpid, |
| 196 | (unsigned long long)xid, | 189 | (unsigned long long)xid, |
| 197 | lkb->lkb_exflags, | 190 | lkb->lkb_exflags, |
| 198 | lkb->lkb_flags, | 191 | lkb->lkb_flags, |
| 199 | lkb->lkb_status, | 192 | lkb->lkb_status, |
| 200 | lkb->lkb_grmode, | 193 | lkb->lkb_grmode, |
| 201 | lkb->lkb_rqmode, | 194 | lkb->lkb_rqmode, |
| 202 | (unsigned long long)us, | 195 | (unsigned long long)us, |
| 203 | r->res_nodeid, | 196 | r->res_nodeid, |
| 204 | r->res_length, | 197 | r->res_length, |
| 205 | r->res_name); | 198 | r->res_name); |
| 206 | return rv; | ||
| 207 | } | 199 | } |
| 208 | 200 | ||
| 209 | static int print_format2(struct dlm_rsb *r, struct seq_file *s) | 201 | static void print_format2(struct dlm_rsb *r, struct seq_file *s) |
| 210 | { | 202 | { |
| 211 | struct dlm_lkb *lkb; | 203 | struct dlm_lkb *lkb; |
| 212 | int rv = 0; | ||
| 213 | 204 | ||
| 214 | lock_rsb(r); | 205 | lock_rsb(r); |
| 215 | 206 | ||
| 216 | list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) { | 207 | list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) { |
| 217 | rv = print_format2_lock(s, lkb, r); | 208 | print_format2_lock(s, lkb, r); |
| 218 | if (rv) | 209 | if (seq_has_overflowed(s)) |
| 219 | goto out; | 210 | goto out; |
| 220 | } | 211 | } |
| 221 | 212 | ||
| 222 | list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) { | 213 | list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) { |
| 223 | rv = print_format2_lock(s, lkb, r); | 214 | print_format2_lock(s, lkb, r); |
| 224 | if (rv) | 215 | if (seq_has_overflowed(s)) |
| 225 | goto out; | 216 | goto out; |
| 226 | } | 217 | } |
| 227 | 218 | ||
| 228 | list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue) { | 219 | list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue) { |
| 229 | rv = print_format2_lock(s, lkb, r); | 220 | print_format2_lock(s, lkb, r); |
| 230 | if (rv) | 221 | if (seq_has_overflowed(s)) |
| 231 | goto out; | 222 | goto out; |
| 232 | } | 223 | } |
| 233 | out: | 224 | out: |
| 234 | unlock_rsb(r); | 225 | unlock_rsb(r); |
| 235 | return rv; | ||
| 236 | } | 226 | } |
| 237 | 227 | ||
| 238 | static int print_format3_lock(struct seq_file *s, struct dlm_lkb *lkb, | 228 | static void print_format3_lock(struct seq_file *s, struct dlm_lkb *lkb, |
| 239 | int rsb_lookup) | 229 | int rsb_lookup) |
| 240 | { | 230 | { |
| 241 | u64 xid = 0; | 231 | u64 xid = 0; |
| 242 | int rv; | ||
| 243 | 232 | ||
| 244 | if (lkb->lkb_flags & DLM_IFL_USER) { | 233 | if (lkb->lkb_flags & DLM_IFL_USER) { |
| 245 | if (lkb->lkb_ua) | 234 | if (lkb->lkb_ua) |
| 246 | xid = lkb->lkb_ua->xid; | 235 | xid = lkb->lkb_ua->xid; |
| 247 | } | 236 | } |
| 248 | 237 | ||
| 249 | rv = seq_printf(s, "lkb %x %d %x %u %llu %x %x %d %d %d %d %d %d %u %llu %llu\n", | 238 | seq_printf(s, "lkb %x %d %x %u %llu %x %x %d %d %d %d %d %d %u %llu %llu\n", |
| 250 | lkb->lkb_id, | 239 | lkb->lkb_id, |
| 251 | lkb->lkb_nodeid, | 240 | lkb->lkb_nodeid, |
| 252 | lkb->lkb_remid, | 241 | lkb->lkb_remid, |
| 253 | lkb->lkb_ownpid, | 242 | lkb->lkb_ownpid, |
| 254 | (unsigned long long)xid, | 243 | (unsigned long long)xid, |
| 255 | lkb->lkb_exflags, | 244 | lkb->lkb_exflags, |
| 256 | lkb->lkb_flags, | 245 | lkb->lkb_flags, |
| 257 | lkb->lkb_status, | 246 | lkb->lkb_status, |
| 258 | lkb->lkb_grmode, | 247 | lkb->lkb_grmode, |
| 259 | lkb->lkb_rqmode, | 248 | lkb->lkb_rqmode, |
| 260 | lkb->lkb_last_bast.mode, | 249 | lkb->lkb_last_bast.mode, |
| 261 | rsb_lookup, | 250 | rsb_lookup, |
| 262 | lkb->lkb_wait_type, | 251 | lkb->lkb_wait_type, |
| 263 | lkb->lkb_lvbseq, | 252 | lkb->lkb_lvbseq, |
| 264 | (unsigned long long)ktime_to_ns(lkb->lkb_timestamp), | 253 | (unsigned long long)ktime_to_ns(lkb->lkb_timestamp), |
| 265 | (unsigned long long)ktime_to_ns(lkb->lkb_last_bast_time)); | 254 | (unsigned long long)ktime_to_ns(lkb->lkb_last_bast_time)); |
| 266 | return rv; | ||
| 267 | } | 255 | } |
| 268 | 256 | ||
| 269 | static int print_format3(struct dlm_rsb *r, struct seq_file *s) | 257 | static void print_format3(struct dlm_rsb *r, struct seq_file *s) |
| 270 | { | 258 | { |
| 271 | struct dlm_lkb *lkb; | 259 | struct dlm_lkb *lkb; |
| 272 | int i, lvblen = r->res_ls->ls_lvblen; | 260 | int i, lvblen = r->res_ls->ls_lvblen; |
| 273 | int print_name = 1; | 261 | int print_name = 1; |
| 274 | int rv; | ||
| 275 | 262 | ||
| 276 | lock_rsb(r); | 263 | lock_rsb(r); |
| 277 | 264 | ||
| 278 | rv = seq_printf(s, "rsb %p %d %x %lx %d %d %u %d ", | 265 | seq_printf(s, "rsb %p %d %x %lx %d %d %u %d ", |
| 279 | r, | 266 | r, |
| 280 | r->res_nodeid, | 267 | r->res_nodeid, |
| 281 | r->res_first_lkid, | 268 | r->res_first_lkid, |
| 282 | r->res_flags, | 269 | r->res_flags, |
| 283 | !list_empty(&r->res_root_list), | 270 | !list_empty(&r->res_root_list), |
| 284 | !list_empty(&r->res_recover_list), | 271 | !list_empty(&r->res_recover_list), |
| 285 | r->res_recover_locks_count, | 272 | r->res_recover_locks_count, |
| 286 | r->res_length); | 273 | r->res_length); |
| 287 | if (rv) | 274 | if (seq_has_overflowed(s)) |
| 288 | goto out; | 275 | goto out; |
| 289 | 276 | ||
| 290 | for (i = 0; i < r->res_length; i++) { | 277 | for (i = 0; i < r->res_length; i++) { |
| @@ -292,7 +279,7 @@ static int print_format3(struct dlm_rsb *r, struct seq_file *s) | |||
| 292 | print_name = 0; | 279 | print_name = 0; |
| 293 | } | 280 | } |
| 294 | 281 | ||
| 295 | seq_printf(s, "%s", print_name ? "str " : "hex"); | 282 | seq_puts(s, print_name ? "str " : "hex"); |
| 296 | 283 | ||
| 297 | for (i = 0; i < r->res_length; i++) { | 284 | for (i = 0; i < r->res_length; i++) { |
| 298 | if (print_name) | 285 | if (print_name) |
| @@ -300,8 +287,8 @@ static int print_format3(struct dlm_rsb *r, struct seq_file *s) | |||
| 300 | else | 287 | else |
| 301 | seq_printf(s, " %02x", (unsigned char)r->res_name[i]); | 288 | seq_printf(s, " %02x", (unsigned char)r->res_name[i]); |
| 302 | } | 289 | } |
| 303 | rv = seq_puts(s, "\n"); | 290 | seq_puts(s, "\n"); |
| 304 | if (rv) | 291 | if (seq_has_overflowed(s)) |
| 305 | goto out; | 292 | goto out; |
| 306 | 293 | ||
| 307 | if (!r->res_lvbptr) | 294 | if (!r->res_lvbptr) |
| @@ -311,65 +298,62 @@ static int print_format3(struct dlm_rsb *r, struct seq_file *s) | |||
| 311 | 298 | ||
| 312 | for (i = 0; i < lvblen; i++) | 299 | for (i = 0; i < lvblen; i++) |
| 313 | seq_printf(s, " %02x", (unsigned char)r->res_lvbptr[i]); | 300 | seq_printf(s, " %02x", (unsigned char)r->res_lvbptr[i]); |
| 314 | rv = seq_puts(s, "\n"); | 301 | seq_puts(s, "\n"); |
| 315 | if (rv) | 302 | if (seq_has_overflowed(s)) |
| 316 | goto out; | 303 | goto out; |
| 317 | 304 | ||
| 318 | do_locks: | 305 | do_locks: |
| 319 | list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) { | 306 | list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) { |
| 320 | rv = print_format3_lock(s, lkb, 0); | 307 | print_format3_lock(s, lkb, 0); |
| 321 | if (rv) | 308 | if (seq_has_overflowed(s)) |
| 322 | goto out; | 309 | goto out; |
| 323 | } | 310 | } |
| 324 | 311 | ||
| 325 | list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) { | 312 | list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) { |
| 326 | rv = print_format3_lock(s, lkb, 0); | 313 | print_format3_lock(s, lkb, 0); |
| 327 | if (rv) | 314 | if (seq_has_overflowed(s)) |
| 328 | goto out; | 315 | goto out; |
| 329 | } | 316 | } |
| 330 | 317 | ||
| 331 | list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue) { | 318 | list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue) { |
| 332 | rv = print_format3_lock(s, lkb, 0); | 319 | print_format3_lock(s, lkb, 0); |
| 333 | if (rv) | 320 | if (seq_has_overflowed(s)) |
| 334 | goto out; | 321 | goto out; |
| 335 | } | 322 | } |
| 336 | 323 | ||
| 337 | list_for_each_entry(lkb, &r->res_lookup, lkb_rsb_lookup) { | 324 | list_for_each_entry(lkb, &r->res_lookup, lkb_rsb_lookup) { |
| 338 | rv = print_format3_lock(s, lkb, 1); | 325 | print_format3_lock(s, lkb, 1); |
| 339 | if (rv) | 326 | if (seq_has_overflowed(s)) |
| 340 | goto out; | 327 | goto out; |
| 341 | } | 328 | } |
| 342 | out: | 329 | out: |
| 343 | unlock_rsb(r); | 330 | unlock_rsb(r); |
| 344 | return rv; | ||
| 345 | } | 331 | } |
| 346 | 332 | ||
| 347 | static int print_format4(struct dlm_rsb *r, struct seq_file *s) | 333 | static void print_format4(struct dlm_rsb *r, struct seq_file *s) |
| 348 | { | 334 | { |
| 349 | int our_nodeid = dlm_our_nodeid(); | 335 | int our_nodeid = dlm_our_nodeid(); |
| 350 | int print_name = 1; | 336 | int print_name = 1; |
| 351 | int i, rv; | 337 | int i; |
| 352 | 338 | ||
| 353 | lock_rsb(r); | 339 | lock_rsb(r); |
| 354 | 340 | ||
| 355 | rv = seq_printf(s, "rsb %p %d %d %d %d %lu %lx %d ", | 341 | seq_printf(s, "rsb %p %d %d %d %d %lu %lx %d ", |
| 356 | r, | 342 | r, |
| 357 | r->res_nodeid, | 343 | r->res_nodeid, |
| 358 | r->res_master_nodeid, | 344 | r->res_master_nodeid, |
| 359 | r->res_dir_nodeid, | 345 | r->res_dir_nodeid, |
| 360 | our_nodeid, | 346 | our_nodeid, |
| 361 | r->res_toss_time, | 347 | r->res_toss_time, |
| 362 | r->res_flags, | 348 | r->res_flags, |
| 363 | r->res_length); | 349 | r->res_length); |
| 364 | if (rv) | ||
| 365 | goto out; | ||
| 366 | 350 | ||
| 367 | for (i = 0; i < r->res_length; i++) { | 351 | for (i = 0; i < r->res_length; i++) { |
| 368 | if (!isascii(r->res_name[i]) || !isprint(r->res_name[i])) | 352 | if (!isascii(r->res_name[i]) || !isprint(r->res_name[i])) |
| 369 | print_name = 0; | 353 | print_name = 0; |
| 370 | } | 354 | } |
| 371 | 355 | ||
| 372 | seq_printf(s, "%s", print_name ? "str " : "hex"); | 356 | seq_puts(s, print_name ? "str " : "hex"); |
| 373 | 357 | ||
| 374 | for (i = 0; i < r->res_length; i++) { | 358 | for (i = 0; i < r->res_length; i++) { |
| 375 | if (print_name) | 359 | if (print_name) |
| @@ -377,10 +361,9 @@ static int print_format4(struct dlm_rsb *r, struct seq_file *s) | |||
| 377 | else | 361 | else |
| 378 | seq_printf(s, " %02x", (unsigned char)r->res_name[i]); | 362 | seq_printf(s, " %02x", (unsigned char)r->res_name[i]); |
| 379 | } | 363 | } |
| 380 | rv = seq_puts(s, "\n"); | 364 | seq_puts(s, "\n"); |
| 381 | out: | 365 | |
| 382 | unlock_rsb(r); | 366 | unlock_rsb(r); |
| 383 | return rv; | ||
| 384 | } | 367 | } |
| 385 | 368 | ||
| 386 | struct rsbtbl_iter { | 369 | struct rsbtbl_iter { |
| @@ -390,47 +373,45 @@ struct rsbtbl_iter { | |||
| 390 | int header; | 373 | int header; |
| 391 | }; | 374 | }; |
| 392 | 375 | ||
| 393 | /* seq_printf returns -1 if the buffer is full, and 0 otherwise. | 376 | /* |
| 394 | If the buffer is full, seq_printf can be called again, but it | 377 | * If the buffer is full, seq_printf can be called again, but it |
| 395 | does nothing and just returns -1. So, the these printing routines | 378 | * does nothing. So, the these printing routines periodically check |
| 396 | periodically check the return value to avoid wasting too much time | 379 | * seq_has_overflowed to avoid wasting too much time trying to print to |
| 397 | trying to print to a full buffer. */ | 380 | * a full buffer. |
| 381 | */ | ||
| 398 | 382 | ||
| 399 | static int table_seq_show(struct seq_file *seq, void *iter_ptr) | 383 | static int table_seq_show(struct seq_file *seq, void *iter_ptr) |
| 400 | { | 384 | { |
| 401 | struct rsbtbl_iter *ri = iter_ptr; | 385 | struct rsbtbl_iter *ri = iter_ptr; |
| 402 | int rv = 0; | ||
| 403 | 386 | ||
| 404 | switch (ri->format) { | 387 | switch (ri->format) { |
| 405 | case 1: | 388 | case 1: |
| 406 | rv = print_format1(ri->rsb, seq); | 389 | print_format1(ri->rsb, seq); |
| 407 | break; | 390 | break; |
| 408 | case 2: | 391 | case 2: |
| 409 | if (ri->header) { | 392 | if (ri->header) { |
| 410 | seq_printf(seq, "id nodeid remid pid xid exflags " | 393 | seq_puts(seq, "id nodeid remid pid xid exflags flags sts grmode rqmode time_ms r_nodeid r_len r_name\n"); |
| 411 | "flags sts grmode rqmode time_ms " | ||
| 412 | "r_nodeid r_len r_name\n"); | ||
| 413 | ri->header = 0; | 394 | ri->header = 0; |
| 414 | } | 395 | } |
| 415 | rv = print_format2(ri->rsb, seq); | 396 | print_format2(ri->rsb, seq); |
| 416 | break; | 397 | break; |
| 417 | case 3: | 398 | case 3: |
| 418 | if (ri->header) { | 399 | if (ri->header) { |
| 419 | seq_printf(seq, "version rsb 1.1 lvb 1.1 lkb 1.1\n"); | 400 | seq_puts(seq, "version rsb 1.1 lvb 1.1 lkb 1.1\n"); |
| 420 | ri->header = 0; | 401 | ri->header = 0; |
| 421 | } | 402 | } |
| 422 | rv = print_format3(ri->rsb, seq); | 403 | print_format3(ri->rsb, seq); |
| 423 | break; | 404 | break; |
| 424 | case 4: | 405 | case 4: |
| 425 | if (ri->header) { | 406 | if (ri->header) { |
| 426 | seq_printf(seq, "version 4 rsb 2\n"); | 407 | seq_puts(seq, "version 4 rsb 2\n"); |
| 427 | ri->header = 0; | 408 | ri->header = 0; |
| 428 | } | 409 | } |
| 429 | rv = print_format4(ri->rsb, seq); | 410 | print_format4(ri->rsb, seq); |
| 430 | break; | 411 | break; |
| 431 | } | 412 | } |
| 432 | 413 | ||
| 433 | return rv; | 414 | return 0; |
| 434 | } | 415 | } |
| 435 | 416 | ||
| 436 | static const struct seq_operations format1_seq_ops; | 417 | static const struct seq_operations format1_seq_ops; |
diff --git a/fs/eventfd.c b/fs/eventfd.c index d6a88e7812f3..4b0a226024fa 100644 --- a/fs/eventfd.c +++ b/fs/eventfd.c | |||
| @@ -287,17 +287,14 @@ static ssize_t eventfd_write(struct file *file, const char __user *buf, size_t c | |||
| 287 | } | 287 | } |
| 288 | 288 | ||
| 289 | #ifdef CONFIG_PROC_FS | 289 | #ifdef CONFIG_PROC_FS |
| 290 | static int eventfd_show_fdinfo(struct seq_file *m, struct file *f) | 290 | static void eventfd_show_fdinfo(struct seq_file *m, struct file *f) |
| 291 | { | 291 | { |
| 292 | struct eventfd_ctx *ctx = f->private_data; | 292 | struct eventfd_ctx *ctx = f->private_data; |
| 293 | int ret; | ||
| 294 | 293 | ||
| 295 | spin_lock_irq(&ctx->wqh.lock); | 294 | spin_lock_irq(&ctx->wqh.lock); |
| 296 | ret = seq_printf(m, "eventfd-count: %16llx\n", | 295 | seq_printf(m, "eventfd-count: %16llx\n", |
| 297 | (unsigned long long)ctx->count); | 296 | (unsigned long long)ctx->count); |
| 298 | spin_unlock_irq(&ctx->wqh.lock); | 297 | spin_unlock_irq(&ctx->wqh.lock); |
| 299 | |||
| 300 | return ret; | ||
| 301 | } | 298 | } |
| 302 | #endif | 299 | #endif |
| 303 | 300 | ||
diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 7bcfff900f05..d77f94491352 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c | |||
| @@ -870,25 +870,22 @@ static unsigned int ep_eventpoll_poll(struct file *file, poll_table *wait) | |||
| 870 | } | 870 | } |
| 871 | 871 | ||
| 872 | #ifdef CONFIG_PROC_FS | 872 | #ifdef CONFIG_PROC_FS |
| 873 | static int ep_show_fdinfo(struct seq_file *m, struct file *f) | 873 | static void ep_show_fdinfo(struct seq_file *m, struct file *f) |
| 874 | { | 874 | { |
| 875 | struct eventpoll *ep = f->private_data; | 875 | struct eventpoll *ep = f->private_data; |
| 876 | struct rb_node *rbp; | 876 | struct rb_node *rbp; |
| 877 | int ret = 0; | ||
| 878 | 877 | ||
| 879 | mutex_lock(&ep->mtx); | 878 | mutex_lock(&ep->mtx); |
| 880 | for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) { | 879 | for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) { |
| 881 | struct epitem *epi = rb_entry(rbp, struct epitem, rbn); | 880 | struct epitem *epi = rb_entry(rbp, struct epitem, rbn); |
| 882 | 881 | ||
| 883 | ret = seq_printf(m, "tfd: %8d events: %8x data: %16llx\n", | 882 | seq_printf(m, "tfd: %8d events: %8x data: %16llx\n", |
| 884 | epi->ffd.fd, epi->event.events, | 883 | epi->ffd.fd, epi->event.events, |
| 885 | (long long)epi->event.data); | 884 | (long long)epi->event.data); |
| 886 | if (ret) | 885 | if (seq_has_overflowed(m)) |
| 887 | break; | 886 | break; |
| 888 | } | 887 | } |
| 889 | mutex_unlock(&ep->mtx); | 888 | mutex_unlock(&ep->mtx); |
| 890 | |||
| 891 | return ret; | ||
| 892 | } | 889 | } |
| 893 | #endif | 890 | #endif |
| 894 | 891 | ||
diff --git a/fs/notify/fdinfo.c b/fs/notify/fdinfo.c index 9d7e2b9659cb..6ffd220eb14d 100644 --- a/fs/notify/fdinfo.c +++ b/fs/notify/fdinfo.c | |||
| @@ -20,25 +20,24 @@ | |||
| 20 | 20 | ||
| 21 | #if defined(CONFIG_INOTIFY_USER) || defined(CONFIG_FANOTIFY) | 21 | #if defined(CONFIG_INOTIFY_USER) || defined(CONFIG_FANOTIFY) |
| 22 | 22 | ||
| 23 | static int show_fdinfo(struct seq_file *m, struct file *f, | 23 | static void show_fdinfo(struct seq_file *m, struct file *f, |
| 24 | int (*show)(struct seq_file *m, struct fsnotify_mark *mark)) | 24 | void (*show)(struct seq_file *m, |
| 25 | struct fsnotify_mark *mark)) | ||
| 25 | { | 26 | { |
| 26 | struct fsnotify_group *group = f->private_data; | 27 | struct fsnotify_group *group = f->private_data; |
| 27 | struct fsnotify_mark *mark; | 28 | struct fsnotify_mark *mark; |
| 28 | int ret = 0; | ||
| 29 | 29 | ||
| 30 | mutex_lock(&group->mark_mutex); | 30 | mutex_lock(&group->mark_mutex); |
| 31 | list_for_each_entry(mark, &group->marks_list, g_list) { | 31 | list_for_each_entry(mark, &group->marks_list, g_list) { |
| 32 | ret = show(m, mark); | 32 | show(m, mark); |
| 33 | if (ret) | 33 | if (seq_has_overflowed(m)) |
| 34 | break; | 34 | break; |
| 35 | } | 35 | } |
| 36 | mutex_unlock(&group->mark_mutex); | 36 | mutex_unlock(&group->mark_mutex); |
| 37 | return ret; | ||
| 38 | } | 37 | } |
| 39 | 38 | ||
| 40 | #if defined(CONFIG_EXPORTFS) | 39 | #if defined(CONFIG_EXPORTFS) |
| 41 | static int show_mark_fhandle(struct seq_file *m, struct inode *inode) | 40 | static void show_mark_fhandle(struct seq_file *m, struct inode *inode) |
| 42 | { | 41 | { |
| 43 | struct { | 42 | struct { |
| 44 | struct file_handle handle; | 43 | struct file_handle handle; |
| @@ -52,71 +51,62 @@ static int show_mark_fhandle(struct seq_file *m, struct inode *inode) | |||
| 52 | ret = exportfs_encode_inode_fh(inode, (struct fid *)f.handle.f_handle, &size, 0); | 51 | ret = exportfs_encode_inode_fh(inode, (struct fid *)f.handle.f_handle, &size, 0); |
| 53 | if ((ret == FILEID_INVALID) || (ret < 0)) { | 52 | if ((ret == FILEID_INVALID) || (ret < 0)) { |
| 54 | WARN_ONCE(1, "Can't encode file handler for inotify: %d\n", ret); | 53 | WARN_ONCE(1, "Can't encode file handler for inotify: %d\n", ret); |
| 55 | return 0; | 54 | return; |
| 56 | } | 55 | } |
| 57 | 56 | ||
| 58 | f.handle.handle_type = ret; | 57 | f.handle.handle_type = ret; |
| 59 | f.handle.handle_bytes = size * sizeof(u32); | 58 | f.handle.handle_bytes = size * sizeof(u32); |
| 60 | 59 | ||
| 61 | ret = seq_printf(m, "fhandle-bytes:%x fhandle-type:%x f_handle:", | 60 | seq_printf(m, "fhandle-bytes:%x fhandle-type:%x f_handle:", |
| 62 | f.handle.handle_bytes, f.handle.handle_type); | 61 | f.handle.handle_bytes, f.handle.handle_type); |
| 63 | 62 | ||
| 64 | for (i = 0; i < f.handle.handle_bytes; i++) | 63 | for (i = 0; i < f.handle.handle_bytes; i++) |
| 65 | ret |= seq_printf(m, "%02x", (int)f.handle.f_handle[i]); | 64 | seq_printf(m, "%02x", (int)f.handle.f_handle[i]); |
| 66 | |||
| 67 | return ret; | ||
| 68 | } | 65 | } |
| 69 | #else | 66 | #else |
| 70 | static int show_mark_fhandle(struct seq_file *m, struct inode *inode) | 67 | static void show_mark_fhandle(struct seq_file *m, struct inode *inode) |
| 71 | { | 68 | { |
| 72 | return 0; | ||
| 73 | } | 69 | } |
| 74 | #endif | 70 | #endif |
| 75 | 71 | ||
| 76 | #ifdef CONFIG_INOTIFY_USER | 72 | #ifdef CONFIG_INOTIFY_USER |
| 77 | 73 | ||
| 78 | static int inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark) | 74 | static void inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark) |
| 79 | { | 75 | { |
| 80 | struct inotify_inode_mark *inode_mark; | 76 | struct inotify_inode_mark *inode_mark; |
| 81 | struct inode *inode; | 77 | struct inode *inode; |
| 82 | int ret = 0; | ||
| 83 | 78 | ||
| 84 | if (!(mark->flags & (FSNOTIFY_MARK_FLAG_ALIVE | FSNOTIFY_MARK_FLAG_INODE))) | 79 | if (!(mark->flags & (FSNOTIFY_MARK_FLAG_ALIVE | FSNOTIFY_MARK_FLAG_INODE))) |
| 85 | return 0; | 80 | return; |
| 86 | 81 | ||
| 87 | inode_mark = container_of(mark, struct inotify_inode_mark, fsn_mark); | 82 | inode_mark = container_of(mark, struct inotify_inode_mark, fsn_mark); |
| 88 | inode = igrab(mark->i.inode); | 83 | inode = igrab(mark->i.inode); |
| 89 | if (inode) { | 84 | if (inode) { |
| 90 | ret = seq_printf(m, "inotify wd:%x ino:%lx sdev:%x " | 85 | seq_printf(m, "inotify wd:%x ino:%lx sdev:%x mask:%x ignored_mask:%x ", |
| 91 | "mask:%x ignored_mask:%x ", | 86 | inode_mark->wd, inode->i_ino, inode->i_sb->s_dev, |
| 92 | inode_mark->wd, inode->i_ino, | 87 | mark->mask, mark->ignored_mask); |
| 93 | inode->i_sb->s_dev, | 88 | show_mark_fhandle(m, inode); |
| 94 | mark->mask, mark->ignored_mask); | 89 | seq_putc(m, '\n'); |
| 95 | ret |= show_mark_fhandle(m, inode); | ||
| 96 | ret |= seq_putc(m, '\n'); | ||
| 97 | iput(inode); | 90 | iput(inode); |
| 98 | } | 91 | } |
| 99 | |||
| 100 | return ret; | ||
| 101 | } | 92 | } |
| 102 | 93 | ||
| 103 | int inotify_show_fdinfo(struct seq_file *m, struct file *f) | 94 | void inotify_show_fdinfo(struct seq_file *m, struct file *f) |
| 104 | { | 95 | { |
| 105 | return show_fdinfo(m, f, inotify_fdinfo); | 96 | show_fdinfo(m, f, inotify_fdinfo); |
| 106 | } | 97 | } |
| 107 | 98 | ||
| 108 | #endif /* CONFIG_INOTIFY_USER */ | 99 | #endif /* CONFIG_INOTIFY_USER */ |
| 109 | 100 | ||
| 110 | #ifdef CONFIG_FANOTIFY | 101 | #ifdef CONFIG_FANOTIFY |
| 111 | 102 | ||
| 112 | static int fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark) | 103 | static void fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark) |
| 113 | { | 104 | { |
| 114 | unsigned int mflags = 0; | 105 | unsigned int mflags = 0; |
| 115 | struct inode *inode; | 106 | struct inode *inode; |
| 116 | int ret = 0; | ||
| 117 | 107 | ||
| 118 | if (!(mark->flags & FSNOTIFY_MARK_FLAG_ALIVE)) | 108 | if (!(mark->flags & FSNOTIFY_MARK_FLAG_ALIVE)) |
| 119 | return 0; | 109 | return; |
| 120 | 110 | ||
| 121 | if (mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY) | 111 | if (mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY) |
| 122 | mflags |= FAN_MARK_IGNORED_SURV_MODIFY; | 112 | mflags |= FAN_MARK_IGNORED_SURV_MODIFY; |
| @@ -124,26 +114,22 @@ static int fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark) | |||
| 124 | if (mark->flags & FSNOTIFY_MARK_FLAG_INODE) { | 114 | if (mark->flags & FSNOTIFY_MARK_FLAG_INODE) { |
| 125 | inode = igrab(mark->i.inode); | 115 | inode = igrab(mark->i.inode); |
| 126 | if (!inode) | 116 | if (!inode) |
| 127 | goto out; | 117 | return; |
| 128 | ret = seq_printf(m, "fanotify ino:%lx sdev:%x " | 118 | seq_printf(m, "fanotify ino:%lx sdev:%x mflags:%x mask:%x ignored_mask:%x ", |
| 129 | "mflags:%x mask:%x ignored_mask:%x ", | 119 | inode->i_ino, inode->i_sb->s_dev, |
| 130 | inode->i_ino, inode->i_sb->s_dev, | 120 | mflags, mark->mask, mark->ignored_mask); |
| 131 | mflags, mark->mask, mark->ignored_mask); | 121 | show_mark_fhandle(m, inode); |
| 132 | ret |= show_mark_fhandle(m, inode); | 122 | seq_putc(m, '\n'); |
| 133 | ret |= seq_putc(m, '\n'); | ||
| 134 | iput(inode); | 123 | iput(inode); |
| 135 | } else if (mark->flags & FSNOTIFY_MARK_FLAG_VFSMOUNT) { | 124 | } else if (mark->flags & FSNOTIFY_MARK_FLAG_VFSMOUNT) { |
| 136 | struct mount *mnt = real_mount(mark->m.mnt); | 125 | struct mount *mnt = real_mount(mark->m.mnt); |
| 137 | 126 | ||
| 138 | ret = seq_printf(m, "fanotify mnt_id:%x mflags:%x mask:%x " | 127 | seq_printf(m, "fanotify mnt_id:%x mflags:%x mask:%x ignored_mask:%x\n", |
| 139 | "ignored_mask:%x\n", mnt->mnt_id, mflags, | 128 | mnt->mnt_id, mflags, mark->mask, mark->ignored_mask); |
| 140 | mark->mask, mark->ignored_mask); | ||
| 141 | } | 129 | } |
| 142 | out: | ||
| 143 | return ret; | ||
| 144 | } | 130 | } |
| 145 | 131 | ||
| 146 | int fanotify_show_fdinfo(struct seq_file *m, struct file *f) | 132 | void fanotify_show_fdinfo(struct seq_file *m, struct file *f) |
| 147 | { | 133 | { |
| 148 | struct fsnotify_group *group = f->private_data; | 134 | struct fsnotify_group *group = f->private_data; |
| 149 | unsigned int flags = 0; | 135 | unsigned int flags = 0; |
| @@ -169,7 +155,7 @@ int fanotify_show_fdinfo(struct seq_file *m, struct file *f) | |||
| 169 | seq_printf(m, "fanotify flags:%x event-flags:%x\n", | 155 | seq_printf(m, "fanotify flags:%x event-flags:%x\n", |
| 170 | flags, group->fanotify_data.f_flags); | 156 | flags, group->fanotify_data.f_flags); |
| 171 | 157 | ||
| 172 | return show_fdinfo(m, f, fanotify_fdinfo); | 158 | show_fdinfo(m, f, fanotify_fdinfo); |
| 173 | } | 159 | } |
| 174 | 160 | ||
| 175 | #endif /* CONFIG_FANOTIFY */ | 161 | #endif /* CONFIG_FANOTIFY */ |
diff --git a/fs/notify/fdinfo.h b/fs/notify/fdinfo.h index 556afda990e9..9664c4904d6b 100644 --- a/fs/notify/fdinfo.h +++ b/fs/notify/fdinfo.h | |||
| @@ -10,11 +10,11 @@ struct file; | |||
| 10 | #ifdef CONFIG_PROC_FS | 10 | #ifdef CONFIG_PROC_FS |
| 11 | 11 | ||
| 12 | #ifdef CONFIG_INOTIFY_USER | 12 | #ifdef CONFIG_INOTIFY_USER |
| 13 | extern int inotify_show_fdinfo(struct seq_file *m, struct file *f); | 13 | void inotify_show_fdinfo(struct seq_file *m, struct file *f); |
| 14 | #endif | 14 | #endif |
| 15 | 15 | ||
| 16 | #ifdef CONFIG_FANOTIFY | 16 | #ifdef CONFIG_FANOTIFY |
| 17 | extern int fanotify_show_fdinfo(struct seq_file *m, struct file *f); | 17 | void fanotify_show_fdinfo(struct seq_file *m, struct file *f); |
| 18 | #endif | 18 | #endif |
| 19 | 19 | ||
| 20 | #else /* CONFIG_PROC_FS */ | 20 | #else /* CONFIG_PROC_FS */ |
diff --git a/fs/proc/fd.c b/fs/proc/fd.c index e11d7c590bb0..8e5ad83b629a 100644 --- a/fs/proc/fd.c +++ b/fs/proc/fd.c | |||
| @@ -53,7 +53,8 @@ static int seq_show(struct seq_file *m, void *v) | |||
| 53 | (long long)file->f_pos, f_flags, | 53 | (long long)file->f_pos, f_flags, |
| 54 | real_mount(file->f_path.mnt)->mnt_id); | 54 | real_mount(file->f_path.mnt)->mnt_id); |
| 55 | if (file->f_op->show_fdinfo) | 55 | if (file->f_op->show_fdinfo) |
| 56 | ret = file->f_op->show_fdinfo(m, file); | 56 | file->f_op->show_fdinfo(m, file); |
| 57 | ret = seq_has_overflowed(m); | ||
| 57 | fput(file); | 58 | fput(file); |
| 58 | } | 59 | } |
| 59 | 60 | ||
diff --git a/fs/seq_file.c b/fs/seq_file.c index 3857b720cb1b..353948ba1c5b 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c | |||
| @@ -16,17 +16,6 @@ | |||
| 16 | #include <asm/uaccess.h> | 16 | #include <asm/uaccess.h> |
| 17 | #include <asm/page.h> | 17 | #include <asm/page.h> |
| 18 | 18 | ||
| 19 | |||
| 20 | /* | ||
| 21 | * seq_files have a buffer which can may overflow. When this happens a larger | ||
| 22 | * buffer is reallocated and all the data will be printed again. | ||
| 23 | * The overflow state is true when m->count == m->size. | ||
| 24 | */ | ||
| 25 | static bool seq_overflow(struct seq_file *m) | ||
| 26 | { | ||
| 27 | return m->count == m->size; | ||
| 28 | } | ||
| 29 | |||
| 30 | static void seq_set_overflow(struct seq_file *m) | 19 | static void seq_set_overflow(struct seq_file *m) |
| 31 | { | 20 | { |
| 32 | m->count = m->size; | 21 | m->count = m->size; |
| @@ -124,7 +113,7 @@ static int traverse(struct seq_file *m, loff_t offset) | |||
| 124 | error = 0; | 113 | error = 0; |
| 125 | m->count = 0; | 114 | m->count = 0; |
| 126 | } | 115 | } |
| 127 | if (seq_overflow(m)) | 116 | if (seq_has_overflowed(m)) |
| 128 | goto Eoverflow; | 117 | goto Eoverflow; |
| 129 | if (pos + m->count > offset) { | 118 | if (pos + m->count > offset) { |
| 130 | m->from = offset - pos; | 119 | m->from = offset - pos; |
| @@ -267,7 +256,7 @@ Fill: | |||
| 267 | break; | 256 | break; |
| 268 | } | 257 | } |
| 269 | err = m->op->show(m, p); | 258 | err = m->op->show(m, p); |
| 270 | if (seq_overflow(m) || err) { | 259 | if (seq_has_overflowed(m) || err) { |
| 271 | m->count = offs; | 260 | m->count = offs; |
| 272 | if (likely(err <= 0)) | 261 | if (likely(err <= 0)) |
| 273 | break; | 262 | break; |
diff --git a/fs/signalfd.c b/fs/signalfd.c index 424b7b65321f..7e412ad74836 100644 --- a/fs/signalfd.c +++ b/fs/signalfd.c | |||
| @@ -230,7 +230,7 @@ static ssize_t signalfd_read(struct file *file, char __user *buf, size_t count, | |||
| 230 | } | 230 | } |
| 231 | 231 | ||
| 232 | #ifdef CONFIG_PROC_FS | 232 | #ifdef CONFIG_PROC_FS |
| 233 | static int signalfd_show_fdinfo(struct seq_file *m, struct file *f) | 233 | static void signalfd_show_fdinfo(struct seq_file *m, struct file *f) |
| 234 | { | 234 | { |
| 235 | struct signalfd_ctx *ctx = f->private_data; | 235 | struct signalfd_ctx *ctx = f->private_data; |
| 236 | sigset_t sigmask; | 236 | sigset_t sigmask; |
| @@ -238,8 +238,6 @@ static int signalfd_show_fdinfo(struct seq_file *m, struct file *f) | |||
| 238 | sigmask = ctx->sigmask; | 238 | sigmask = ctx->sigmask; |
| 239 | signotset(&sigmask); | 239 | signotset(&sigmask); |
| 240 | render_sigset_t(m, "sigmask:\t", &sigmask); | 240 | render_sigset_t(m, "sigmask:\t", &sigmask); |
| 241 | |||
| 242 | return 0; | ||
| 243 | } | 241 | } |
| 244 | #endif | 242 | #endif |
| 245 | 243 | ||
diff --git a/fs/timerfd.c b/fs/timerfd.c index b46ffa94372a..b94fa6c3c6eb 100644 --- a/fs/timerfd.c +++ b/fs/timerfd.c | |||
| @@ -288,7 +288,7 @@ static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count, | |||
| 288 | } | 288 | } |
| 289 | 289 | ||
| 290 | #ifdef CONFIG_PROC_FS | 290 | #ifdef CONFIG_PROC_FS |
| 291 | static int timerfd_show(struct seq_file *m, struct file *file) | 291 | static void timerfd_show(struct seq_file *m, struct file *file) |
| 292 | { | 292 | { |
| 293 | struct timerfd_ctx *ctx = file->private_data; | 293 | struct timerfd_ctx *ctx = file->private_data; |
| 294 | struct itimerspec t; | 294 | struct itimerspec t; |
| @@ -298,18 +298,19 @@ static int timerfd_show(struct seq_file *m, struct file *file) | |||
| 298 | t.it_interval = ktime_to_timespec(ctx->tintv); | 298 | t.it_interval = ktime_to_timespec(ctx->tintv); |
| 299 | spin_unlock_irq(&ctx->wqh.lock); | 299 | spin_unlock_irq(&ctx->wqh.lock); |
| 300 | 300 | ||
| 301 | return seq_printf(m, | 301 | seq_printf(m, |
| 302 | "clockid: %d\n" | 302 | "clockid: %d\n" |
| 303 | "ticks: %llu\n" | 303 | "ticks: %llu\n" |
| 304 | "settime flags: 0%o\n" | 304 | "settime flags: 0%o\n" |
| 305 | "it_value: (%llu, %llu)\n" | 305 | "it_value: (%llu, %llu)\n" |
| 306 | "it_interval: (%llu, %llu)\n", | 306 | "it_interval: (%llu, %llu)\n", |
| 307 | ctx->clockid, (unsigned long long)ctx->ticks, | 307 | ctx->clockid, |
| 308 | ctx->settime_flags, | 308 | (unsigned long long)ctx->ticks, |
| 309 | (unsigned long long)t.it_value.tv_sec, | 309 | ctx->settime_flags, |
| 310 | (unsigned long long)t.it_value.tv_nsec, | 310 | (unsigned long long)t.it_value.tv_sec, |
| 311 | (unsigned long long)t.it_interval.tv_sec, | 311 | (unsigned long long)t.it_value.tv_nsec, |
| 312 | (unsigned long long)t.it_interval.tv_nsec); | 312 | (unsigned long long)t.it_interval.tv_sec, |
| 313 | (unsigned long long)t.it_interval.tv_nsec); | ||
| 313 | } | 314 | } |
| 314 | #else | 315 | #else |
| 315 | #define timerfd_show NULL | 316 | #define timerfd_show NULL |
diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h index 4d0b4d1aa132..d84f8c254a87 100644 --- a/include/linux/debugfs.h +++ b/include/linux/debugfs.h | |||
| @@ -92,8 +92,8 @@ struct dentry *debugfs_create_regset32(const char *name, umode_t mode, | |||
| 92 | struct dentry *parent, | 92 | struct dentry *parent, |
| 93 | struct debugfs_regset32 *regset); | 93 | struct debugfs_regset32 *regset); |
| 94 | 94 | ||
| 95 | int debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs, | 95 | void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs, |
| 96 | int nregs, void __iomem *base, char *prefix); | 96 | int nregs, void __iomem *base, char *prefix); |
| 97 | 97 | ||
| 98 | struct dentry *debugfs_create_u32_array(const char *name, umode_t mode, | 98 | struct dentry *debugfs_create_u32_array(const char *name, umode_t mode, |
| 99 | struct dentry *parent, | 99 | struct dentry *parent, |
| @@ -233,10 +233,9 @@ static inline struct dentry *debugfs_create_regset32(const char *name, | |||
| 233 | return ERR_PTR(-ENODEV); | 233 | return ERR_PTR(-ENODEV); |
| 234 | } | 234 | } |
| 235 | 235 | ||
| 236 | static inline int debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs, | 236 | static inline void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs, |
| 237 | int nregs, void __iomem *base, char *prefix) | 237 | int nregs, void __iomem *base, char *prefix) |
| 238 | { | 238 | { |
| 239 | return 0; | ||
| 240 | } | 239 | } |
| 241 | 240 | ||
| 242 | static inline bool debugfs_initialized(void) | 241 | static inline bool debugfs_initialized(void) |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 1a8bb3c023a1..2beddc284bc2 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
| @@ -1515,7 +1515,7 @@ struct file_operations { | |||
| 1515 | int (*setlease)(struct file *, long, struct file_lock **, void **); | 1515 | int (*setlease)(struct file *, long, struct file_lock **, void **); |
| 1516 | long (*fallocate)(struct file *file, int mode, loff_t offset, | 1516 | long (*fallocate)(struct file *file, int mode, loff_t offset, |
| 1517 | loff_t len); | 1517 | loff_t len); |
| 1518 | int (*show_fdinfo)(struct seq_file *m, struct file *f); | 1518 | void (*show_fdinfo)(struct seq_file *m, struct file *f); |
| 1519 | }; | 1519 | }; |
| 1520 | 1520 | ||
| 1521 | struct inode_operations { | 1521 | struct inode_operations { |
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h index 52e0097f61f0..cf6a9daaaf6d 100644 --- a/include/linux/seq_file.h +++ b/include/linux/seq_file.h | |||
| @@ -43,6 +43,21 @@ struct seq_operations { | |||
| 43 | #define SEQ_SKIP 1 | 43 | #define SEQ_SKIP 1 |
| 44 | 44 | ||
| 45 | /** | 45 | /** |
| 46 | * seq_has_overflowed - check if the buffer has overflowed | ||
| 47 | * @m: the seq_file handle | ||
| 48 | * | ||
| 49 | * seq_files have a buffer which may overflow. When this happens a larger | ||
| 50 | * buffer is reallocated and all the data will be printed again. | ||
| 51 | * The overflow state is true when m->count == m->size. | ||
| 52 | * | ||
| 53 | * Returns true if the buffer received more than it can hold. | ||
| 54 | */ | ||
| 55 | static inline bool seq_has_overflowed(struct seq_file *m) | ||
| 56 | { | ||
| 57 | return m->count == m->size; | ||
| 58 | } | ||
| 59 | |||
| 60 | /** | ||
| 46 | * seq_get_buf - get buffer to write arbitrary data to | 61 | * seq_get_buf - get buffer to write arbitrary data to |
| 47 | * @m: the seq_file handle | 62 | * @m: the seq_file handle |
| 48 | * @bufp: the beginning of the buffer is stored here | 63 | * @bufp: the beginning of the buffer is stored here |
diff --git a/include/net/netfilter/nf_conntrack_core.h b/include/net/netfilter/nf_conntrack_core.h index cc0c18827602..f2f0fa3bb150 100644 --- a/include/net/netfilter/nf_conntrack_core.h +++ b/include/net/netfilter/nf_conntrack_core.h | |||
| @@ -72,7 +72,7 @@ static inline int nf_conntrack_confirm(struct sk_buff *skb) | |||
| 72 | return ret; | 72 | return ret; |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | int | 75 | void |
| 76 | print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple, | 76 | print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple, |
| 77 | const struct nf_conntrack_l3proto *l3proto, | 77 | const struct nf_conntrack_l3proto *l3proto, |
| 78 | const struct nf_conntrack_l4proto *proto); | 78 | const struct nf_conntrack_l4proto *proto); |
diff --git a/include/net/netfilter/nf_conntrack_l3proto.h b/include/net/netfilter/nf_conntrack_l3proto.h index adc1fa3dd7ab..cdc920b4c4c2 100644 --- a/include/net/netfilter/nf_conntrack_l3proto.h +++ b/include/net/netfilter/nf_conntrack_l3proto.h | |||
| @@ -38,8 +38,8 @@ struct nf_conntrack_l3proto { | |||
| 38 | const struct nf_conntrack_tuple *orig); | 38 | const struct nf_conntrack_tuple *orig); |
| 39 | 39 | ||
| 40 | /* Print out the per-protocol part of the tuple. */ | 40 | /* Print out the per-protocol part of the tuple. */ |
| 41 | int (*print_tuple)(struct seq_file *s, | 41 | void (*print_tuple)(struct seq_file *s, |
| 42 | const struct nf_conntrack_tuple *); | 42 | const struct nf_conntrack_tuple *); |
| 43 | 43 | ||
| 44 | /* | 44 | /* |
| 45 | * Called before tracking. | 45 | * Called before tracking. |
diff --git a/include/net/netfilter/nf_conntrack_l4proto.h b/include/net/netfilter/nf_conntrack_l4proto.h index 4c8d573830b7..1f7061313d54 100644 --- a/include/net/netfilter/nf_conntrack_l4proto.h +++ b/include/net/netfilter/nf_conntrack_l4proto.h | |||
| @@ -56,11 +56,11 @@ struct nf_conntrack_l4proto { | |||
| 56 | u_int8_t pf, unsigned int hooknum); | 56 | u_int8_t pf, unsigned int hooknum); |
| 57 | 57 | ||
| 58 | /* Print out the per-protocol part of the tuple. Return like seq_* */ | 58 | /* Print out the per-protocol part of the tuple. Return like seq_* */ |
| 59 | int (*print_tuple)(struct seq_file *s, | 59 | void (*print_tuple)(struct seq_file *s, |
| 60 | const struct nf_conntrack_tuple *); | 60 | const struct nf_conntrack_tuple *); |
| 61 | 61 | ||
| 62 | /* Print out the private part of the conntrack. */ | 62 | /* Print out the private part of the conntrack. */ |
| 63 | int (*print_conntrack)(struct seq_file *s, struct nf_conn *); | 63 | void (*print_conntrack)(struct seq_file *s, struct nf_conn *); |
| 64 | 64 | ||
| 65 | /* Return the array of timeouts for this protocol. */ | 65 | /* Return the array of timeouts for this protocol. */ |
| 66 | unsigned int *(*get_timeouts)(struct net *net); | 66 | unsigned int *(*get_timeouts)(struct net *net); |
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c index a054fe083431..5c61328b7704 100644 --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | |||
| @@ -56,11 +56,11 @@ static bool ipv4_invert_tuple(struct nf_conntrack_tuple *tuple, | |||
| 56 | return true; | 56 | return true; |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | static int ipv4_print_tuple(struct seq_file *s, | 59 | static void ipv4_print_tuple(struct seq_file *s, |
| 60 | const struct nf_conntrack_tuple *tuple) | 60 | const struct nf_conntrack_tuple *tuple) |
| 61 | { | 61 | { |
| 62 | return seq_printf(s, "src=%pI4 dst=%pI4 ", | 62 | seq_printf(s, "src=%pI4 dst=%pI4 ", |
| 63 | &tuple->src.u3.ip, &tuple->dst.u3.ip); | 63 | &tuple->src.u3.ip, &tuple->dst.u3.ip); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | static int ipv4_get_l4proto(const struct sk_buff *skb, unsigned int nhoff, | 66 | static int ipv4_get_l4proto(const struct sk_buff *skb, unsigned int nhoff, |
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c index 4c48e434bb1f..a460a87e14f8 100644 --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c | |||
| @@ -94,7 +94,7 @@ static void ct_seq_stop(struct seq_file *s, void *v) | |||
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | #ifdef CONFIG_NF_CONNTRACK_SECMARK | 96 | #ifdef CONFIG_NF_CONNTRACK_SECMARK |
| 97 | static int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct) | 97 | static void ct_show_secctx(struct seq_file *s, const struct nf_conn *ct) |
| 98 | { | 98 | { |
| 99 | int ret; | 99 | int ret; |
| 100 | u32 len; | 100 | u32 len; |
| @@ -102,17 +102,15 @@ static int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct) | |||
| 102 | 102 | ||
| 103 | ret = security_secid_to_secctx(ct->secmark, &secctx, &len); | 103 | ret = security_secid_to_secctx(ct->secmark, &secctx, &len); |
| 104 | if (ret) | 104 | if (ret) |
| 105 | return 0; | 105 | return; |
| 106 | 106 | ||
| 107 | ret = seq_printf(s, "secctx=%s ", secctx); | 107 | seq_printf(s, "secctx=%s ", secctx); |
| 108 | 108 | ||
| 109 | security_release_secctx(secctx, len); | 109 | security_release_secctx(secctx, len); |
| 110 | return ret; | ||
| 111 | } | 110 | } |
| 112 | #else | 111 | #else |
| 113 | static inline int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct) | 112 | static inline void ct_show_secctx(struct seq_file *s, const struct nf_conn *ct) |
| 114 | { | 113 | { |
| 115 | return 0; | ||
| 116 | } | 114 | } |
| 117 | #endif | 115 | #endif |
| 118 | 116 | ||
| @@ -141,47 +139,52 @@ static int ct_seq_show(struct seq_file *s, void *v) | |||
| 141 | NF_CT_ASSERT(l4proto); | 139 | NF_CT_ASSERT(l4proto); |
| 142 | 140 | ||
| 143 | ret = -ENOSPC; | 141 | ret = -ENOSPC; |
| 144 | if (seq_printf(s, "%-8s %u %ld ", | 142 | seq_printf(s, "%-8s %u %ld ", |
| 145 | l4proto->name, nf_ct_protonum(ct), | 143 | l4proto->name, nf_ct_protonum(ct), |
| 146 | timer_pending(&ct->timeout) | 144 | timer_pending(&ct->timeout) |
| 147 | ? (long)(ct->timeout.expires - jiffies)/HZ : 0) != 0) | 145 | ? (long)(ct->timeout.expires - jiffies)/HZ : 0); |
| 148 | goto release; | 146 | |
| 147 | if (l4proto->print_conntrack) | ||
| 148 | l4proto->print_conntrack(s, ct); | ||
| 149 | 149 | ||
| 150 | if (l4proto->print_conntrack && l4proto->print_conntrack(s, ct)) | 150 | if (seq_has_overflowed(s)) |
| 151 | goto release; | 151 | goto release; |
| 152 | 152 | ||
| 153 | if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple, | 153 | print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple, |
| 154 | l3proto, l4proto)) | 154 | l3proto, l4proto); |
| 155 | |||
| 156 | if (seq_has_overflowed(s)) | ||
| 155 | goto release; | 157 | goto release; |
| 156 | 158 | ||
| 157 | if (seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL)) | 159 | if (seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL)) |
| 158 | goto release; | 160 | goto release; |
| 159 | 161 | ||
| 160 | if (!(test_bit(IPS_SEEN_REPLY_BIT, &ct->status))) | 162 | if (!(test_bit(IPS_SEEN_REPLY_BIT, &ct->status))) |
| 161 | if (seq_printf(s, "[UNREPLIED] ")) | 163 | seq_printf(s, "[UNREPLIED] "); |
| 162 | goto release; | ||
| 163 | 164 | ||
| 164 | if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple, | 165 | print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple, |
| 165 | l3proto, l4proto)) | 166 | l3proto, l4proto); |
| 167 | |||
| 168 | if (seq_has_overflowed(s)) | ||
| 166 | goto release; | 169 | goto release; |
| 167 | 170 | ||
| 168 | if (seq_print_acct(s, ct, IP_CT_DIR_REPLY)) | 171 | if (seq_print_acct(s, ct, IP_CT_DIR_REPLY)) |
| 169 | goto release; | 172 | goto release; |
| 170 | 173 | ||
| 171 | if (test_bit(IPS_ASSURED_BIT, &ct->status)) | 174 | if (test_bit(IPS_ASSURED_BIT, &ct->status)) |
| 172 | if (seq_printf(s, "[ASSURED] ")) | 175 | seq_printf(s, "[ASSURED] "); |
| 173 | goto release; | ||
| 174 | 176 | ||
| 175 | #ifdef CONFIG_NF_CONNTRACK_MARK | 177 | #ifdef CONFIG_NF_CONNTRACK_MARK |
| 176 | if (seq_printf(s, "mark=%u ", ct->mark)) | 178 | seq_printf(s, "mark=%u ", ct->mark); |
| 177 | goto release; | ||
| 178 | #endif | 179 | #endif |
| 179 | 180 | ||
| 180 | if (ct_show_secctx(s, ct)) | 181 | ct_show_secctx(s, ct); |
| 181 | goto release; | ||
| 182 | 182 | ||
| 183 | if (seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use))) | 183 | seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use)); |
| 184 | |||
| 185 | if (seq_has_overflowed(s)) | ||
| 184 | goto release; | 186 | goto release; |
| 187 | |||
| 185 | ret = 0; | 188 | ret = 0; |
| 186 | release: | 189 | release: |
| 187 | nf_ct_put(ct); | 190 | nf_ct_put(ct); |
diff --git a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c index b91b2641adda..80d5554b9a88 100644 --- a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c +++ b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c | |||
| @@ -72,13 +72,13 @@ static bool icmp_invert_tuple(struct nf_conntrack_tuple *tuple, | |||
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | /* Print out the per-protocol part of the tuple. */ | 74 | /* Print out the per-protocol part of the tuple. */ |
| 75 | static int icmp_print_tuple(struct seq_file *s, | 75 | static void icmp_print_tuple(struct seq_file *s, |
| 76 | const struct nf_conntrack_tuple *tuple) | 76 | const struct nf_conntrack_tuple *tuple) |
| 77 | { | 77 | { |
| 78 | return seq_printf(s, "type=%u code=%u id=%u ", | 78 | seq_printf(s, "type=%u code=%u id=%u ", |
| 79 | tuple->dst.u.icmp.type, | 79 | tuple->dst.u.icmp.type, |
| 80 | tuple->dst.u.icmp.code, | 80 | tuple->dst.u.icmp.code, |
| 81 | ntohs(tuple->src.u.icmp.id)); | 81 | ntohs(tuple->src.u.icmp.id)); |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | static unsigned int *icmp_get_timeouts(struct net *net) | 84 | static unsigned int *icmp_get_timeouts(struct net *net) |
diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c index 4cbc6b290dd5..b68d0e59c1f8 100644 --- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c +++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | |||
| @@ -60,11 +60,11 @@ static bool ipv6_invert_tuple(struct nf_conntrack_tuple *tuple, | |||
| 60 | return true; | 60 | return true; |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | static int ipv6_print_tuple(struct seq_file *s, | 63 | static void ipv6_print_tuple(struct seq_file *s, |
| 64 | const struct nf_conntrack_tuple *tuple) | 64 | const struct nf_conntrack_tuple *tuple) |
| 65 | { | 65 | { |
| 66 | return seq_printf(s, "src=%pI6 dst=%pI6 ", | 66 | seq_printf(s, "src=%pI6 dst=%pI6 ", |
| 67 | tuple->src.u3.ip6, tuple->dst.u3.ip6); | 67 | tuple->src.u3.ip6, tuple->dst.u3.ip6); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | static int ipv6_get_l4proto(const struct sk_buff *skb, unsigned int nhoff, | 70 | static int ipv6_get_l4proto(const struct sk_buff *skb, unsigned int nhoff, |
diff --git a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c index b3807c5cb888..90388d606483 100644 --- a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +++ b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | |||
| @@ -84,13 +84,13 @@ static bool icmpv6_invert_tuple(struct nf_conntrack_tuple *tuple, | |||
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | /* Print out the per-protocol part of the tuple. */ | 86 | /* Print out the per-protocol part of the tuple. */ |
| 87 | static int icmpv6_print_tuple(struct seq_file *s, | 87 | static void icmpv6_print_tuple(struct seq_file *s, |
| 88 | const struct nf_conntrack_tuple *tuple) | 88 | const struct nf_conntrack_tuple *tuple) |
| 89 | { | 89 | { |
| 90 | return seq_printf(s, "type=%u code=%u id=%u ", | 90 | seq_printf(s, "type=%u code=%u id=%u ", |
| 91 | tuple->dst.u.icmp.type, | 91 | tuple->dst.u.icmp.type, |
| 92 | tuple->dst.u.icmp.code, | 92 | tuple->dst.u.icmp.code, |
| 93 | ntohs(tuple->src.u.icmp.id)); | 93 | ntohs(tuple->src.u.icmp.id)); |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | static unsigned int *icmpv6_get_timeouts(struct net *net) | 96 | static unsigned int *icmpv6_get_timeouts(struct net *net) |
diff --git a/net/netfilter/nf_conntrack_l3proto_generic.c b/net/netfilter/nf_conntrack_l3proto_generic.c index e7eb807fe07d..cf9ace70bece 100644 --- a/net/netfilter/nf_conntrack_l3proto_generic.c +++ b/net/netfilter/nf_conntrack_l3proto_generic.c | |||
| @@ -49,10 +49,9 @@ static bool generic_invert_tuple(struct nf_conntrack_tuple *tuple, | |||
| 49 | return true; | 49 | return true; |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | static int generic_print_tuple(struct seq_file *s, | 52 | static void generic_print_tuple(struct seq_file *s, |
| 53 | const struct nf_conntrack_tuple *tuple) | 53 | const struct nf_conntrack_tuple *tuple) |
| 54 | { | 54 | { |
| 55 | return 0; | ||
| 56 | } | 55 | } |
| 57 | 56 | ||
| 58 | static int generic_get_l4proto(const struct sk_buff *skb, unsigned int nhoff, | 57 | static int generic_get_l4proto(const struct sk_buff *skb, unsigned int nhoff, |
diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c index cb372f96f10d..6dd995c7c72b 100644 --- a/net/netfilter/nf_conntrack_proto_dccp.c +++ b/net/netfilter/nf_conntrack_proto_dccp.c | |||
| @@ -618,17 +618,17 @@ out_invalid: | |||
| 618 | return -NF_ACCEPT; | 618 | return -NF_ACCEPT; |
| 619 | } | 619 | } |
| 620 | 620 | ||
| 621 | static int dccp_print_tuple(struct seq_file *s, | 621 | static void dccp_print_tuple(struct seq_file *s, |
| 622 | const struct nf_conntrack_tuple *tuple) | 622 | const struct nf_conntrack_tuple *tuple) |
| 623 | { | 623 | { |
| 624 | return seq_printf(s, "sport=%hu dport=%hu ", | 624 | seq_printf(s, "sport=%hu dport=%hu ", |
| 625 | ntohs(tuple->src.u.dccp.port), | 625 | ntohs(tuple->src.u.dccp.port), |
| 626 | ntohs(tuple->dst.u.dccp.port)); | 626 | ntohs(tuple->dst.u.dccp.port)); |
| 627 | } | 627 | } |
| 628 | 628 | ||
| 629 | static int dccp_print_conntrack(struct seq_file *s, struct nf_conn *ct) | 629 | static void dccp_print_conntrack(struct seq_file *s, struct nf_conn *ct) |
| 630 | { | 630 | { |
| 631 | return seq_printf(s, "%s ", dccp_state_names[ct->proto.dccp.state]); | 631 | seq_printf(s, "%s ", dccp_state_names[ct->proto.dccp.state]); |
| 632 | } | 632 | } |
| 633 | 633 | ||
| 634 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK) | 634 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK) |
diff --git a/net/netfilter/nf_conntrack_proto_generic.c b/net/netfilter/nf_conntrack_proto_generic.c index 957c1db66652..60865f110309 100644 --- a/net/netfilter/nf_conntrack_proto_generic.c +++ b/net/netfilter/nf_conntrack_proto_generic.c | |||
| @@ -63,10 +63,9 @@ static bool generic_invert_tuple(struct nf_conntrack_tuple *tuple, | |||
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | /* Print out the per-protocol part of the tuple. */ | 65 | /* Print out the per-protocol part of the tuple. */ |
| 66 | static int generic_print_tuple(struct seq_file *s, | 66 | static void generic_print_tuple(struct seq_file *s, |
| 67 | const struct nf_conntrack_tuple *tuple) | 67 | const struct nf_conntrack_tuple *tuple) |
| 68 | { | 68 | { |
| 69 | return 0; | ||
| 70 | } | 69 | } |
| 71 | 70 | ||
| 72 | static unsigned int *generic_get_timeouts(struct net *net) | 71 | static unsigned int *generic_get_timeouts(struct net *net) |
diff --git a/net/netfilter/nf_conntrack_proto_gre.c b/net/netfilter/nf_conntrack_proto_gre.c index d5665739e3b1..7648674f29c3 100644 --- a/net/netfilter/nf_conntrack_proto_gre.c +++ b/net/netfilter/nf_conntrack_proto_gre.c | |||
| @@ -226,20 +226,20 @@ static bool gre_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff, | |||
| 226 | } | 226 | } |
| 227 | 227 | ||
| 228 | /* print gre part of tuple */ | 228 | /* print gre part of tuple */ |
| 229 | static int gre_print_tuple(struct seq_file *s, | 229 | static void gre_print_tuple(struct seq_file *s, |
| 230 | const struct nf_conntrack_tuple *tuple) | 230 | const struct nf_conntrack_tuple *tuple) |
| 231 | { | 231 | { |
| 232 | return seq_printf(s, "srckey=0x%x dstkey=0x%x ", | 232 | seq_printf(s, "srckey=0x%x dstkey=0x%x ", |
| 233 | ntohs(tuple->src.u.gre.key), | 233 | ntohs(tuple->src.u.gre.key), |
| 234 | ntohs(tuple->dst.u.gre.key)); | 234 | ntohs(tuple->dst.u.gre.key)); |
| 235 | } | 235 | } |
| 236 | 236 | ||
| 237 | /* print private data for conntrack */ | 237 | /* print private data for conntrack */ |
| 238 | static int gre_print_conntrack(struct seq_file *s, struct nf_conn *ct) | 238 | static void gre_print_conntrack(struct seq_file *s, struct nf_conn *ct) |
| 239 | { | 239 | { |
| 240 | return seq_printf(s, "timeout=%u, stream_timeout=%u ", | 240 | seq_printf(s, "timeout=%u, stream_timeout=%u ", |
| 241 | (ct->proto.gre.timeout / HZ), | 241 | (ct->proto.gre.timeout / HZ), |
| 242 | (ct->proto.gre.stream_timeout / HZ)); | 242 | (ct->proto.gre.stream_timeout / HZ)); |
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | static unsigned int *gre_get_timeouts(struct net *net) | 245 | static unsigned int *gre_get_timeouts(struct net *net) |
diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c index 1314d33f6bcf..b45da90fad32 100644 --- a/net/netfilter/nf_conntrack_proto_sctp.c +++ b/net/netfilter/nf_conntrack_proto_sctp.c | |||
| @@ -166,16 +166,16 @@ static bool sctp_invert_tuple(struct nf_conntrack_tuple *tuple, | |||
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | /* Print out the per-protocol part of the tuple. */ | 168 | /* Print out the per-protocol part of the tuple. */ |
| 169 | static int sctp_print_tuple(struct seq_file *s, | 169 | static void sctp_print_tuple(struct seq_file *s, |
| 170 | const struct nf_conntrack_tuple *tuple) | 170 | const struct nf_conntrack_tuple *tuple) |
| 171 | { | 171 | { |
| 172 | return seq_printf(s, "sport=%hu dport=%hu ", | 172 | seq_printf(s, "sport=%hu dport=%hu ", |
| 173 | ntohs(tuple->src.u.sctp.port), | 173 | ntohs(tuple->src.u.sctp.port), |
| 174 | ntohs(tuple->dst.u.sctp.port)); | 174 | ntohs(tuple->dst.u.sctp.port)); |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | /* Print out the private part of the conntrack. */ | 177 | /* Print out the private part of the conntrack. */ |
| 178 | static int sctp_print_conntrack(struct seq_file *s, struct nf_conn *ct) | 178 | static void sctp_print_conntrack(struct seq_file *s, struct nf_conn *ct) |
| 179 | { | 179 | { |
| 180 | enum sctp_conntrack state; | 180 | enum sctp_conntrack state; |
| 181 | 181 | ||
| @@ -183,7 +183,7 @@ static int sctp_print_conntrack(struct seq_file *s, struct nf_conn *ct) | |||
| 183 | state = ct->proto.sctp.state; | 183 | state = ct->proto.sctp.state; |
| 184 | spin_unlock_bh(&ct->lock); | 184 | spin_unlock_bh(&ct->lock); |
| 185 | 185 | ||
| 186 | return seq_printf(s, "%s ", sctp_conntrack_names[state]); | 186 | seq_printf(s, "%s ", sctp_conntrack_names[state]); |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | #define for_each_sctp_chunk(skb, sch, _sch, offset, dataoff, count) \ | 189 | #define for_each_sctp_chunk(skb, sch, _sch, offset, dataoff, count) \ |
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c index 44d1ea32570a..36a3ac8ee9f5 100644 --- a/net/netfilter/nf_conntrack_proto_tcp.c +++ b/net/netfilter/nf_conntrack_proto_tcp.c | |||
| @@ -302,16 +302,16 @@ static bool tcp_invert_tuple(struct nf_conntrack_tuple *tuple, | |||
| 302 | } | 302 | } |
| 303 | 303 | ||
| 304 | /* Print out the per-protocol part of the tuple. */ | 304 | /* Print out the per-protocol part of the tuple. */ |
| 305 | static int tcp_print_tuple(struct seq_file *s, | 305 | static void tcp_print_tuple(struct seq_file *s, |
| 306 | const struct nf_conntrack_tuple *tuple) | 306 | const struct nf_conntrack_tuple *tuple) |
| 307 | { | 307 | { |
| 308 | return seq_printf(s, "sport=%hu dport=%hu ", | 308 | seq_printf(s, "sport=%hu dport=%hu ", |
| 309 | ntohs(tuple->src.u.tcp.port), | 309 | ntohs(tuple->src.u.tcp.port), |
| 310 | ntohs(tuple->dst.u.tcp.port)); | 310 | ntohs(tuple->dst.u.tcp.port)); |
| 311 | } | 311 | } |
| 312 | 312 | ||
| 313 | /* Print out the private part of the conntrack. */ | 313 | /* Print out the private part of the conntrack. */ |
| 314 | static int tcp_print_conntrack(struct seq_file *s, struct nf_conn *ct) | 314 | static void tcp_print_conntrack(struct seq_file *s, struct nf_conn *ct) |
| 315 | { | 315 | { |
| 316 | enum tcp_conntrack state; | 316 | enum tcp_conntrack state; |
| 317 | 317 | ||
| @@ -319,7 +319,7 @@ static int tcp_print_conntrack(struct seq_file *s, struct nf_conn *ct) | |||
| 319 | state = ct->proto.tcp.state; | 319 | state = ct->proto.tcp.state; |
| 320 | spin_unlock_bh(&ct->lock); | 320 | spin_unlock_bh(&ct->lock); |
| 321 | 321 | ||
| 322 | return seq_printf(s, "%s ", tcp_conntrack_names[state]); | 322 | seq_printf(s, "%s ", tcp_conntrack_names[state]); |
| 323 | } | 323 | } |
| 324 | 324 | ||
| 325 | static unsigned int get_conntrack_index(const struct tcphdr *tcph) | 325 | static unsigned int get_conntrack_index(const struct tcphdr *tcph) |
diff --git a/net/netfilter/nf_conntrack_proto_udp.c b/net/netfilter/nf_conntrack_proto_udp.c index 9d7721cbce4b..6957281ffee5 100644 --- a/net/netfilter/nf_conntrack_proto_udp.c +++ b/net/netfilter/nf_conntrack_proto_udp.c | |||
| @@ -63,12 +63,12 @@ static bool udp_invert_tuple(struct nf_conntrack_tuple *tuple, | |||
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | /* Print out the per-protocol part of the tuple. */ | 65 | /* Print out the per-protocol part of the tuple. */ |
| 66 | static int udp_print_tuple(struct seq_file *s, | 66 | static void udp_print_tuple(struct seq_file *s, |
| 67 | const struct nf_conntrack_tuple *tuple) | 67 | const struct nf_conntrack_tuple *tuple) |
| 68 | { | 68 | { |
| 69 | return seq_printf(s, "sport=%hu dport=%hu ", | 69 | seq_printf(s, "sport=%hu dport=%hu ", |
| 70 | ntohs(tuple->src.u.udp.port), | 70 | ntohs(tuple->src.u.udp.port), |
| 71 | ntohs(tuple->dst.u.udp.port)); | 71 | ntohs(tuple->dst.u.udp.port)); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | static unsigned int *udp_get_timeouts(struct net *net) | 74 | static unsigned int *udp_get_timeouts(struct net *net) |
diff --git a/net/netfilter/nf_conntrack_proto_udplite.c b/net/netfilter/nf_conntrack_proto_udplite.c index 2750e6c69f82..c5903d1649f9 100644 --- a/net/netfilter/nf_conntrack_proto_udplite.c +++ b/net/netfilter/nf_conntrack_proto_udplite.c | |||
| @@ -71,12 +71,12 @@ static bool udplite_invert_tuple(struct nf_conntrack_tuple *tuple, | |||
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | /* Print out the per-protocol part of the tuple. */ | 73 | /* Print out the per-protocol part of the tuple. */ |
| 74 | static int udplite_print_tuple(struct seq_file *s, | 74 | static void udplite_print_tuple(struct seq_file *s, |
| 75 | const struct nf_conntrack_tuple *tuple) | 75 | const struct nf_conntrack_tuple *tuple) |
| 76 | { | 76 | { |
| 77 | return seq_printf(s, "sport=%hu dport=%hu ", | 77 | seq_printf(s, "sport=%hu dport=%hu ", |
| 78 | ntohs(tuple->src.u.udp.port), | 78 | ntohs(tuple->src.u.udp.port), |
| 79 | ntohs(tuple->dst.u.udp.port)); | 79 | ntohs(tuple->dst.u.udp.port)); |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | static unsigned int *udplite_get_timeouts(struct net *net) | 82 | static unsigned int *udplite_get_timeouts(struct net *net) |
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c index cf65a1e040dd..fc823fa5dcf5 100644 --- a/net/netfilter/nf_conntrack_standalone.c +++ b/net/netfilter/nf_conntrack_standalone.c | |||
| @@ -36,12 +36,13 @@ | |||
| 36 | MODULE_LICENSE("GPL"); | 36 | MODULE_LICENSE("GPL"); |
| 37 | 37 | ||
| 38 | #ifdef CONFIG_NF_CONNTRACK_PROCFS | 38 | #ifdef CONFIG_NF_CONNTRACK_PROCFS |
| 39 | int | 39 | void |
| 40 | print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple, | 40 | print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple, |
| 41 | const struct nf_conntrack_l3proto *l3proto, | 41 | const struct nf_conntrack_l3proto *l3proto, |
| 42 | const struct nf_conntrack_l4proto *l4proto) | 42 | const struct nf_conntrack_l4proto *l4proto) |
| 43 | { | 43 | { |
| 44 | return l3proto->print_tuple(s, tuple) || l4proto->print_tuple(s, tuple); | 44 | l3proto->print_tuple(s, tuple); |
| 45 | l4proto->print_tuple(s, tuple); | ||
| 45 | } | 46 | } |
| 46 | EXPORT_SYMBOL_GPL(print_tuple); | 47 | EXPORT_SYMBOL_GPL(print_tuple); |
| 47 | 48 | ||
| @@ -119,7 +120,7 @@ static void ct_seq_stop(struct seq_file *s, void *v) | |||
| 119 | } | 120 | } |
| 120 | 121 | ||
| 121 | #ifdef CONFIG_NF_CONNTRACK_SECMARK | 122 | #ifdef CONFIG_NF_CONNTRACK_SECMARK |
| 122 | static int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct) | 123 | static void ct_show_secctx(struct seq_file *s, const struct nf_conn *ct) |
| 123 | { | 124 | { |
| 124 | int ret; | 125 | int ret; |
| 125 | u32 len; | 126 | u32 len; |
| @@ -127,22 +128,20 @@ static int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct) | |||
| 127 | 128 | ||
| 128 | ret = security_secid_to_secctx(ct->secmark, &secctx, &len); | 129 | ret = security_secid_to_secctx(ct->secmark, &secctx, &len); |
| 129 | if (ret) | 130 | if (ret) |
| 130 | return 0; | 131 | return; |
| 131 | 132 | ||
| 132 | ret = seq_printf(s, "secctx=%s ", secctx); | 133 | seq_printf(s, "secctx=%s ", secctx); |
| 133 | 134 | ||
| 134 | security_release_secctx(secctx, len); | 135 | security_release_secctx(secctx, len); |
| 135 | return ret; | ||
| 136 | } | 136 | } |
| 137 | #else | 137 | #else |
| 138 | static inline int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct) | 138 | static inline void ct_show_secctx(struct seq_file *s, const struct nf_conn *ct) |
| 139 | { | 139 | { |
| 140 | return 0; | ||
| 141 | } | 140 | } |
| 142 | #endif | 141 | #endif |
| 143 | 142 | ||
| 144 | #ifdef CONFIG_NF_CONNTRACK_TIMESTAMP | 143 | #ifdef CONFIG_NF_CONNTRACK_TIMESTAMP |
| 145 | static int ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct) | 144 | static void ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct) |
| 146 | { | 145 | { |
| 147 | struct ct_iter_state *st = s->private; | 146 | struct ct_iter_state *st = s->private; |
| 148 | struct nf_conn_tstamp *tstamp; | 147 | struct nf_conn_tstamp *tstamp; |
| @@ -156,16 +155,15 @@ static int ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct) | |||
| 156 | else | 155 | else |
| 157 | delta_time = 0; | 156 | delta_time = 0; |
| 158 | 157 | ||
| 159 | return seq_printf(s, "delta-time=%llu ", | 158 | seq_printf(s, "delta-time=%llu ", |
| 160 | (unsigned long long)delta_time); | 159 | (unsigned long long)delta_time); |
| 161 | } | 160 | } |
| 162 | return 0; | 161 | return; |
| 163 | } | 162 | } |
| 164 | #else | 163 | #else |
| 165 | static inline int | 164 | static inline void |
| 166 | ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct) | 165 | ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct) |
| 167 | { | 166 | { |
| 168 | return 0; | ||
| 169 | } | 167 | } |
| 170 | #endif | 168 | #endif |
| 171 | 169 | ||
| @@ -192,55 +190,54 @@ static int ct_seq_show(struct seq_file *s, void *v) | |||
| 192 | NF_CT_ASSERT(l4proto); | 190 | NF_CT_ASSERT(l4proto); |
| 193 | 191 | ||
| 194 | ret = -ENOSPC; | 192 | ret = -ENOSPC; |
| 195 | if (seq_printf(s, "%-8s %u %-8s %u %ld ", | 193 | seq_printf(s, "%-8s %u %-8s %u %ld ", |
| 196 | l3proto->name, nf_ct_l3num(ct), | 194 | l3proto->name, nf_ct_l3num(ct), |
| 197 | l4proto->name, nf_ct_protonum(ct), | 195 | l4proto->name, nf_ct_protonum(ct), |
| 198 | timer_pending(&ct->timeout) | 196 | timer_pending(&ct->timeout) |
| 199 | ? (long)(ct->timeout.expires - jiffies)/HZ : 0) != 0) | 197 | ? (long)(ct->timeout.expires - jiffies)/HZ : 0); |
| 200 | goto release; | ||
| 201 | 198 | ||
| 202 | if (l4proto->print_conntrack && l4proto->print_conntrack(s, ct)) | 199 | if (l4proto->print_conntrack) |
| 203 | goto release; | 200 | l4proto->print_conntrack(s, ct); |
| 201 | |||
| 202 | print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple, | ||
| 203 | l3proto, l4proto); | ||
| 204 | 204 | ||
| 205 | if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple, | 205 | if (seq_has_overflowed(s)) |
| 206 | l3proto, l4proto)) | ||
| 207 | goto release; | 206 | goto release; |
| 208 | 207 | ||
| 209 | if (seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL)) | 208 | if (seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL)) |
| 210 | goto release; | 209 | goto release; |
| 211 | 210 | ||
| 212 | if (!(test_bit(IPS_SEEN_REPLY_BIT, &ct->status))) | 211 | if (!(test_bit(IPS_SEEN_REPLY_BIT, &ct->status))) |
| 213 | if (seq_printf(s, "[UNREPLIED] ")) | 212 | seq_printf(s, "[UNREPLIED] "); |
| 214 | goto release; | ||
| 215 | 213 | ||
| 216 | if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple, | 214 | print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple, |
| 217 | l3proto, l4proto)) | 215 | l3proto, l4proto); |
| 218 | goto release; | ||
| 219 | 216 | ||
| 220 | if (seq_print_acct(s, ct, IP_CT_DIR_REPLY)) | 217 | if (seq_print_acct(s, ct, IP_CT_DIR_REPLY)) |
| 221 | goto release; | 218 | goto release; |
| 222 | 219 | ||
| 223 | if (test_bit(IPS_ASSURED_BIT, &ct->status)) | 220 | if (test_bit(IPS_ASSURED_BIT, &ct->status)) |
| 224 | if (seq_printf(s, "[ASSURED] ")) | 221 | seq_printf(s, "[ASSURED] "); |
| 225 | goto release; | ||
| 226 | 222 | ||
| 227 | #if defined(CONFIG_NF_CONNTRACK_MARK) | 223 | if (seq_has_overflowed(s)) |
| 228 | if (seq_printf(s, "mark=%u ", ct->mark)) | ||
| 229 | goto release; | 224 | goto release; |
| 225 | |||
| 226 | #if defined(CONFIG_NF_CONNTRACK_MARK) | ||
| 227 | seq_printf(s, "mark=%u ", ct->mark); | ||
| 230 | #endif | 228 | #endif |
| 231 | 229 | ||
| 232 | if (ct_show_secctx(s, ct)) | 230 | ct_show_secctx(s, ct); |
| 233 | goto release; | ||
| 234 | 231 | ||
| 235 | #ifdef CONFIG_NF_CONNTRACK_ZONES | 232 | #ifdef CONFIG_NF_CONNTRACK_ZONES |
| 236 | if (seq_printf(s, "zone=%u ", nf_ct_zone(ct))) | 233 | seq_printf(s, "zone=%u ", nf_ct_zone(ct)); |
| 237 | goto release; | ||
| 238 | #endif | 234 | #endif |
| 239 | 235 | ||
| 240 | if (ct_show_delta_time(s, ct)) | 236 | ct_show_delta_time(s, ct); |
| 241 | goto release; | 237 | |
| 238 | seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use)); | ||
| 242 | 239 | ||
| 243 | if (seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use))) | 240 | if (seq_has_overflowed(s)) |
| 244 | goto release; | 241 | goto release; |
| 245 | 242 | ||
| 246 | ret = 0; | 243 | ret = 0; |
diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c index d7197649dba6..6e3b9117db1f 100644 --- a/net/netfilter/nf_log.c +++ b/net/netfilter/nf_log.c | |||
| @@ -294,19 +294,19 @@ static int seq_show(struct seq_file *s, void *v) | |||
| 294 | { | 294 | { |
| 295 | loff_t *pos = v; | 295 | loff_t *pos = v; |
| 296 | const struct nf_logger *logger; | 296 | const struct nf_logger *logger; |
| 297 | int i, ret; | 297 | int i; |
| 298 | struct net *net = seq_file_net(s); | 298 | struct net *net = seq_file_net(s); |
| 299 | 299 | ||
| 300 | logger = rcu_dereference_protected(net->nf.nf_loggers[*pos], | 300 | logger = rcu_dereference_protected(net->nf.nf_loggers[*pos], |
| 301 | lockdep_is_held(&nf_log_mutex)); | 301 | lockdep_is_held(&nf_log_mutex)); |
| 302 | 302 | ||
| 303 | if (!logger) | 303 | if (!logger) |
| 304 | ret = seq_printf(s, "%2lld NONE (", *pos); | 304 | seq_printf(s, "%2lld NONE (", *pos); |
| 305 | else | 305 | else |
| 306 | ret = seq_printf(s, "%2lld %s (", *pos, logger->name); | 306 | seq_printf(s, "%2lld %s (", *pos, logger->name); |
| 307 | 307 | ||
| 308 | if (ret < 0) | 308 | if (seq_has_overflowed(s)) |
| 309 | return ret; | 309 | return -ENOSPC; |
| 310 | 310 | ||
| 311 | for (i = 0; i < NF_LOG_TYPE_MAX; i++) { | 311 | for (i = 0; i < NF_LOG_TYPE_MAX; i++) { |
| 312 | if (loggers[*pos][i] == NULL) | 312 | if (loggers[*pos][i] == NULL) |
| @@ -314,17 +314,19 @@ static int seq_show(struct seq_file *s, void *v) | |||
| 314 | 314 | ||
| 315 | logger = rcu_dereference_protected(loggers[*pos][i], | 315 | logger = rcu_dereference_protected(loggers[*pos][i], |
| 316 | lockdep_is_held(&nf_log_mutex)); | 316 | lockdep_is_held(&nf_log_mutex)); |
| 317 | ret = seq_printf(s, "%s", logger->name); | 317 | seq_printf(s, "%s", logger->name); |
| 318 | if (ret < 0) | 318 | if (i == 0 && loggers[*pos][i + 1] != NULL) |
| 319 | return ret; | 319 | seq_printf(s, ","); |
| 320 | if (i == 0 && loggers[*pos][i + 1] != NULL) { | 320 | |
| 321 | ret = seq_printf(s, ","); | 321 | if (seq_has_overflowed(s)) |
| 322 | if (ret < 0) | 322 | return -ENOSPC; |
| 323 | return ret; | ||
| 324 | } | ||
| 325 | } | 323 | } |
| 326 | 324 | ||
| 327 | return seq_printf(s, ")\n"); | 325 | seq_printf(s, ")\n"); |
| 326 | |||
| 327 | if (seq_has_overflowed(s)) | ||
| 328 | return -ENOSPC; | ||
| 329 | return 0; | ||
| 328 | } | 330 | } |
| 329 | 331 | ||
| 330 | static const struct seq_operations nflog_seq_ops = { | 332 | static const struct seq_operations nflog_seq_ops = { |
diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c index a82077d9f59b..f823f1538c4f 100644 --- a/net/netfilter/nfnetlink_queue_core.c +++ b/net/netfilter/nfnetlink_queue_core.c | |||
| @@ -1242,12 +1242,13 @@ static int seq_show(struct seq_file *s, void *v) | |||
| 1242 | { | 1242 | { |
| 1243 | const struct nfqnl_instance *inst = v; | 1243 | const struct nfqnl_instance *inst = v; |
| 1244 | 1244 | ||
| 1245 | return seq_printf(s, "%5d %6d %5d %1d %5d %5d %5d %8d %2d\n", | 1245 | seq_printf(s, "%5d %6d %5d %1d %5d %5d %5d %8d %2d\n", |
| 1246 | inst->queue_num, | 1246 | inst->queue_num, |
| 1247 | inst->peer_portid, inst->queue_total, | 1247 | inst->peer_portid, inst->queue_total, |
| 1248 | inst->copy_mode, inst->copy_range, | 1248 | inst->copy_mode, inst->copy_range, |
| 1249 | inst->queue_dropped, inst->queue_user_dropped, | 1249 | inst->queue_dropped, inst->queue_user_dropped, |
| 1250 | inst->id_sequence, 1); | 1250 | inst->id_sequence, 1); |
| 1251 | return seq_has_overflowed(s); | ||
| 1251 | } | 1252 | } |
| 1252 | 1253 | ||
| 1253 | static const struct seq_operations nfqnl_seq_ops = { | 1254 | static const struct seq_operations nfqnl_seq_ops = { |
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index 133eb4772f12..51a459c3c649 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c | |||
| @@ -947,9 +947,10 @@ static int xt_table_seq_show(struct seq_file *seq, void *v) | |||
| 947 | { | 947 | { |
| 948 | struct xt_table *table = list_entry(v, struct xt_table, list); | 948 | struct xt_table *table = list_entry(v, struct xt_table, list); |
| 949 | 949 | ||
| 950 | if (strlen(table->name)) | 950 | if (strlen(table->name)) { |
| 951 | return seq_printf(seq, "%s\n", table->name); | 951 | seq_printf(seq, "%s\n", table->name); |
| 952 | else | 952 | return seq_has_overflowed(seq); |
| 953 | } else | ||
| 953 | return 0; | 954 | return 0; |
| 954 | } | 955 | } |
| 955 | 956 | ||
| @@ -1086,8 +1087,10 @@ static int xt_match_seq_show(struct seq_file *seq, void *v) | |||
| 1086 | if (trav->curr == trav->head) | 1087 | if (trav->curr == trav->head) |
| 1087 | return 0; | 1088 | return 0; |
| 1088 | match = list_entry(trav->curr, struct xt_match, list); | 1089 | match = list_entry(trav->curr, struct xt_match, list); |
| 1089 | return (*match->name == '\0') ? 0 : | 1090 | if (*match->name == '\0') |
| 1090 | seq_printf(seq, "%s\n", match->name); | 1091 | return 0; |
| 1092 | seq_printf(seq, "%s\n", match->name); | ||
| 1093 | return seq_has_overflowed(seq); | ||
| 1091 | } | 1094 | } |
| 1092 | return 0; | 1095 | return 0; |
| 1093 | } | 1096 | } |
| @@ -1139,8 +1142,10 @@ static int xt_target_seq_show(struct seq_file *seq, void *v) | |||
| 1139 | if (trav->curr == trav->head) | 1142 | if (trav->curr == trav->head) |
| 1140 | return 0; | 1143 | return 0; |
| 1141 | target = list_entry(trav->curr, struct xt_target, list); | 1144 | target = list_entry(trav->curr, struct xt_target, list); |
| 1142 | return (*target->name == '\0') ? 0 : | 1145 | if (*target->name == '\0') |
| 1143 | seq_printf(seq, "%s\n", target->name); | 1146 | return 0; |
| 1147 | seq_printf(seq, "%s\n", target->name); | ||
| 1148 | return seq_has_overflowed(seq); | ||
| 1144 | } | 1149 | } |
| 1145 | return 0; | 1150 | return 0; |
| 1146 | } | 1151 | } |
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c index 05fbc2a0be46..178696852bde 100644 --- a/net/netfilter/xt_hashlimit.c +++ b/net/netfilter/xt_hashlimit.c | |||
| @@ -789,7 +789,6 @@ static void dl_seq_stop(struct seq_file *s, void *v) | |||
| 789 | static int dl_seq_real_show(struct dsthash_ent *ent, u_int8_t family, | 789 | static int dl_seq_real_show(struct dsthash_ent *ent, u_int8_t family, |
| 790 | struct seq_file *s) | 790 | struct seq_file *s) |
| 791 | { | 791 | { |
| 792 | int res; | ||
| 793 | const struct xt_hashlimit_htable *ht = s->private; | 792 | const struct xt_hashlimit_htable *ht = s->private; |
| 794 | 793 | ||
| 795 | spin_lock(&ent->lock); | 794 | spin_lock(&ent->lock); |
| @@ -798,33 +797,32 @@ static int dl_seq_real_show(struct dsthash_ent *ent, u_int8_t family, | |||
| 798 | 797 | ||
| 799 | switch (family) { | 798 | switch (family) { |
| 800 | case NFPROTO_IPV4: | 799 | case NFPROTO_IPV4: |
| 801 | res = seq_printf(s, "%ld %pI4:%u->%pI4:%u %u %u %u\n", | 800 | seq_printf(s, "%ld %pI4:%u->%pI4:%u %u %u %u\n", |
| 802 | (long)(ent->expires - jiffies)/HZ, | 801 | (long)(ent->expires - jiffies)/HZ, |
| 803 | &ent->dst.ip.src, | 802 | &ent->dst.ip.src, |
| 804 | ntohs(ent->dst.src_port), | 803 | ntohs(ent->dst.src_port), |
| 805 | &ent->dst.ip.dst, | 804 | &ent->dst.ip.dst, |
| 806 | ntohs(ent->dst.dst_port), | 805 | ntohs(ent->dst.dst_port), |
| 807 | ent->rateinfo.credit, ent->rateinfo.credit_cap, | 806 | ent->rateinfo.credit, ent->rateinfo.credit_cap, |
| 808 | ent->rateinfo.cost); | 807 | ent->rateinfo.cost); |
| 809 | break; | 808 | break; |
| 810 | #if IS_ENABLED(CONFIG_IP6_NF_IPTABLES) | 809 | #if IS_ENABLED(CONFIG_IP6_NF_IPTABLES) |
| 811 | case NFPROTO_IPV6: | 810 | case NFPROTO_IPV6: |
| 812 | res = seq_printf(s, "%ld %pI6:%u->%pI6:%u %u %u %u\n", | 811 | seq_printf(s, "%ld %pI6:%u->%pI6:%u %u %u %u\n", |
| 813 | (long)(ent->expires - jiffies)/HZ, | 812 | (long)(ent->expires - jiffies)/HZ, |
| 814 | &ent->dst.ip6.src, | 813 | &ent->dst.ip6.src, |
| 815 | ntohs(ent->dst.src_port), | 814 | ntohs(ent->dst.src_port), |
| 816 | &ent->dst.ip6.dst, | 815 | &ent->dst.ip6.dst, |
| 817 | ntohs(ent->dst.dst_port), | 816 | ntohs(ent->dst.dst_port), |
| 818 | ent->rateinfo.credit, ent->rateinfo.credit_cap, | 817 | ent->rateinfo.credit, ent->rateinfo.credit_cap, |
| 819 | ent->rateinfo.cost); | 818 | ent->rateinfo.cost); |
| 820 | break; | 819 | break; |
| 821 | #endif | 820 | #endif |
| 822 | default: | 821 | default: |
| 823 | BUG(); | 822 | BUG(); |
| 824 | res = 0; | ||
| 825 | } | 823 | } |
| 826 | spin_unlock(&ent->lock); | 824 | spin_unlock(&ent->lock); |
| 827 | return res; | 825 | return seq_has_overflowed(s); |
| 828 | } | 826 | } |
| 829 | 827 | ||
| 830 | static int dl_seq_show(struct seq_file *s, void *v) | 828 | static int dl_seq_show(struct seq_file *s, void *v) |
