From bdc218e352f819092818e7df337e99cf33fa2263 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Thu, 15 Oct 2009 14:16:27 -0700 Subject: wireshark: update with latest version, some other fixes --- wireshark/ceph/ceph_fs.h | 529 ++++++++++--------------------------------- wireshark/ceph/msgr.h | 38 ++-- wireshark/ceph/packet-ceph.c | 112 ++++----- wireshark/ceph/plugin.c | 7 +- wireshark/ceph/rados.h | 154 ++++--------- wireshark/ceph/types.h | 52 +++++ 6 files changed, 290 insertions(+), 602 deletions(-) create mode 100644 wireshark/ceph/types.h (limited to 'wireshark') diff --git a/wireshark/ceph/ceph_fs.h b/wireshark/ceph/ceph_fs.h index 27a5a26a0d4..56af192cb43 100644 --- a/wireshark/ceph/ceph_fs.h +++ b/wireshark/ceph/ceph_fs.h @@ -15,6 +15,20 @@ #include "msgr.h" #include "rados.h" +/* + * Ceph release version + */ +#define CEPH_VERSION_MAJOR 0 +#define CEPH_VERSION_MINOR 16 +#define CEPH_VERSION_PATCH 1 + +#define _CEPH_STRINGIFY(x) #x +#define CEPH_STRINGIFY(x) _CEPH_STRINGIFY(x) +#define CEPH_MAKE_VERSION(x, y, z) CEPH_STRINGIFY(x) "." CEPH_STRINGIFY(y) \ + "." CEPH_STRINGIFY(z) +#define CEPH_VERSION CEPH_MAKE_VERSION(CEPH_VERSION_MAJOR, \ + CEPH_VERSION_MINOR, CEPH_VERSION_PATCH) + /* * subprotocol versions. when specific messages types or high-level * protocols change, bump the affected components. we keep rev @@ -23,10 +37,10 @@ */ #define CEPH_OSD_PROTOCOL 7 /* cluster internal */ #define CEPH_MDS_PROTOCOL 9 /* cluster internal */ -#define CEPH_MON_PROTOCOL 4 /* cluster internal */ +#define CEPH_MON_PROTOCOL 5 /* cluster internal */ #define CEPH_OSDC_PROTOCOL 20 /* server/client */ -#define CEPH_MDSC_PROTOCOL 28 /* server/client */ -#define CEPH_MONC_PROTOCOL 14 /* server/client */ +#define CEPH_MDSC_PROTOCOL 29 /* server/client */ +#define CEPH_MONC_PROTOCOL 15 /* server/client */ #define CEPH_INO_ROOT 1 @@ -35,125 +49,7 @@ #define CEPH_MAX_MON 31 -/* - * "Frags" are a way to describe a subset of a 32-bit number space, - * using a mask and a value to match against that mask. Any given frag - * (subset of the number space) can be partitioned into 2^n sub-frags. - * - * Frags are encoded into a 32-bit word: - * 8 upper bits = "bits" - * 24 lower bits = "value" - * (We could go to 5+27 bits, but who cares.) - * - * We use the _most_ significant bits of the 24 bit value. This makes - * values logically sort. - * - * Unfortunately, because the "bits" field is still in the high bits, we - * can't sort encoded frags numerically. However, it does allow you - * to feed encoded frags as values into frag_contains_value. - */ -static inline __u32 frag_make(__u32 b, __u32 v) -{ - return (b << 24) | - (v & (0xffffffu << (24-b)) & 0xffffffu); -} -static inline __u32 frag_bits(__u32 f) -{ - return f >> 24; -} -static inline __u32 frag_value(__u32 f) -{ - return f & 0xffffffu; -} -static inline __u32 frag_mask(__u32 f) -{ - return (0xffffffu << (24-frag_bits(f))) & 0xffffffu; -} -static inline __u32 frag_mask_shift(__u32 f) -{ - return 24 - frag_bits(f); -} - -static inline int frag_contains_value(__u32 f, __u32 v) -{ - return (v & frag_mask(f)) == frag_value(f); -} -static inline int frag_contains_frag(__u32 f, __u32 sub) -{ - /* is sub as specific as us, and contained by us? */ - return frag_bits(sub) >= frag_bits(f) && - (frag_value(sub) & frag_mask(f)) == frag_value(f); -} - -static inline __u32 frag_parent(__u32 f) -{ - return frag_make(frag_bits(f) - 1, - frag_value(f) & (frag_mask(f) << 1)); -} -static inline int frag_is_left_child(__u32 f) -{ - return frag_bits(f) > 0 && - (frag_value(f) & (0x1000000 >> frag_bits(f))) == 0; -} -static inline int frag_is_right_child(__u32 f) -{ - return frag_bits(f) > 0 && - (frag_value(f) & (0x1000000 >> frag_bits(f))) == 1; -} -static inline __u32 frag_sibling(__u32 f) -{ - return frag_make(frag_bits(f), - frag_value(f) ^ (0x1000000 >> frag_bits(f))); -} -static inline __u32 frag_left_child(__u32 f) -{ - return frag_make(frag_bits(f)+1, frag_value(f)); -} -static inline __u32 frag_right_child(__u32 f) -{ - return frag_make(frag_bits(f)+1, - frag_value(f) | (0x1000000 >> (1+frag_bits(f)))); -} -static inline __u32 frag_make_child(__u32 f, int by, int i) -{ - int newbits = frag_bits(f) + by; - return frag_make(newbits, - frag_value(f) | (i << (24 - newbits))); -} -static inline int frag_is_leftmost(__u32 f) -{ - return frag_value(f) == 0; -} -static inline int frag_is_rightmost(__u32 f) -{ - return frag_value(f) == frag_mask(f); -} -static inline __u32 frag_next(__u32 f) -{ - return frag_make(frag_bits(f), - frag_value(f) + (0x1000000 >> frag_bits(f))); -} - -/* - * comparator to sort frags logically, as when traversing the - * number space in ascending order... - */ -static inline int frag_compare(__u32 a, __u32 b) -{ - unsigned va = frag_value(a); - unsigned vb = frag_value(b); - if (va < vb) - return -1; - if (va > vb) - return 1; - va = frag_bits(a); - vb = frag_bits(b); - if (va < vb) - return -1; - if (va > vb) - return 1; - return 0; -} +unsigned int ceph_full_name_hash(const char *name, unsigned int len); /* @@ -176,64 +72,9 @@ struct ceph_file_layout { __le32 fl_pg_pool; /* namespace, crush ruleset, rep level */ } __attribute__ ((packed)); -#define ceph_file_layout_su(l) ((__s32)le32_to_cpu((l).fl_stripe_unit)) -#define ceph_file_layout_stripe_count(l) \ - ((__s32)le32_to_cpu((l).fl_stripe_count)) -#define ceph_file_layout_object_size(l) ((__s32)le32_to_cpu((l).fl_object_size)) -#define ceph_file_layout_cas_hash(l) ((__s32)le32_to_cpu((l).fl_cas_hash)) -#define ceph_file_layout_object_su(l) \ - ((__s32)le32_to_cpu((l).fl_object_stripe_unit)) -#define ceph_file_layout_pg_preferred(l) \ - ((__s32)le32_to_cpu((l).fl_pg_preferred)) -#define ceph_file_layout_pg_pool(l) \ - ((__s32)le32_to_cpu((l).fl_pg_pool)) - -#define ceph_file_layout_stripe_width(l) (le32_to_cpu((l).fl_stripe_unit) * \ - le32_to_cpu((l).fl_stripe_count)) - -/* "period" == bytes before i start on a new set of objects */ -#define ceph_file_layout_period(l) (le32_to_cpu((l).fl_object_size) * \ - le32_to_cpu((l).fl_stripe_count)) - - - -/* - * string hash. - * - * taken from Linux, tho we should probably take care to use this one - * in case the upstream hash changes. - */ - -/* Name hashing routines. Initial hash value */ -/* Hash courtesy of the R5 hash in reiserfs modulo sign bits */ -#define ceph_init_name_hash() 0 - -/* partial hash update function. Assume roughly 4 bits per character */ -static inline unsigned long -ceph_partial_name_hash(unsigned long c, unsigned long prevhash) -{ - return (prevhash + (c << 4) + (c >> 4)) * 11; -} - -/* - * Finally: cut down the number of bits to a int value (and try to avoid - * losing bits) - */ -static inline unsigned long ceph_end_name_hash(unsigned long hash) -{ - return (unsigned int) hash; -} - -/* Compute the hash for a name string. */ -static inline unsigned int -ceph_full_name_hash(const char *name, unsigned int len) -{ - unsigned long hash = ceph_init_name_hash(); - while (len--) - hash = ceph_partial_name_hash(*name++, hash); - return ceph_end_name_hash(hash); -} +#define CEPH_MIN_STRIPE_UNIT 65536 +int ceph_file_layout_is_valid(const struct ceph_file_layout *layout); /********************************************* @@ -253,12 +94,12 @@ ceph_full_name_hash(const char *name, unsigned int len) #define CEPH_MSG_MON_GET_MAP 5 #define CEPH_MSG_CLIENT_MOUNT 10 #define CEPH_MSG_CLIENT_MOUNT_ACK 11 -#define CEPH_MSG_CLIENT_UNMOUNT 12 #define CEPH_MSG_STATFS 13 #define CEPH_MSG_STATFS_REPLY 14 +#define CEPH_MSG_MON_SUBSCRIBE 15 +#define CEPH_MSG_MON_SUBSCRIBE_ACK 16 /* client <-> mds */ -#define CEPH_MSG_MDS_GETMAP 20 #define CEPH_MSG_MDS_MAP 21 #define CEPH_MSG_CLIENT_SESSION 22 @@ -273,15 +114,19 @@ ceph_full_name_hash(const char *name, unsigned int len) #define CEPH_MSG_CLIENT_CAPRELEASE 0x313 /* osd */ -#define CEPH_MSG_OSD_GETMAP 40 #define CEPH_MSG_OSD_MAP 41 #define CEPH_MSG_OSD_OP 42 #define CEPH_MSG_OSD_OPREPLY 43 +struct ceph_mon_request_header { + __le64 have_version; + __le16 session_mon; + __le64 session_mon_tid; +} __attribute__ ((packed)); struct ceph_mon_statfs { - __le64 have_version; - ceph_fsid_t fsid; + struct ceph_mon_request_header monhdr; + struct ceph_fsid fsid; __le64 tid; } __attribute__ ((packed)); @@ -291,29 +136,30 @@ struct ceph_statfs { } __attribute__ ((packed)); struct ceph_mon_statfs_reply { - ceph_fsid_t fsid; + struct ceph_fsid fsid; __le64 tid; __le64 version; struct ceph_statfs st; } __attribute__ ((packed)); struct ceph_osd_getmap { - __le64 have_version; - ceph_fsid_t fsid; + struct ceph_mon_request_header monhdr; + struct ceph_fsid fsid; __le32 start; } __attribute__ ((packed)); struct ceph_mds_getmap { - __le64 have_version; - ceph_fsid_t fsid; + struct ceph_mon_request_header monhdr; + struct ceph_fsid fsid; } __attribute__ ((packed)); struct ceph_client_mount { - __le64 have_version; + struct ceph_mon_request_header monhdr; } __attribute__ ((packed)); -struct ceph_client_unmount { - __le64 have_version; +struct ceph_mon_subscribe_item { + __le64 have_version; __le64 have; + __u8 onetime; } __attribute__ ((packed)); /* @@ -327,7 +173,7 @@ struct ceph_client_unmount { #define CEPH_MDS_STATE_BOOT -4 /* up, boot announcement. */ #define CEPH_MDS_STATE_STANDBY -5 /* up, idle. waiting for assignment. */ #define CEPH_MDS_STATE_CREATING -6 /* up, creating MDS instance. */ -#define CEPH_MDS_STATE_STARTING -7 /* up, starting previously stopped mds. */ +#define CEPH_MDS_STATE_STARTING -7 /* up, starting previously stopped mds */ #define CEPH_MDS_STATE_STANDBY_REPLAY -8 /* up, tailing active node's journal */ #define CEPH_MDS_STATE_REPLAY 8 /* up, replaying journal. */ @@ -339,30 +185,7 @@ struct ceph_client_unmount { #define CEPH_MDS_STATE_ACTIVE 13 /* up, active */ #define CEPH_MDS_STATE_STOPPING 14 /* up, but exporting metadata */ -static inline const char *ceph_mds_state_name(int s) -{ - switch (s) { - /* down and out */ - case CEPH_MDS_STATE_DNE: return "down:dne"; - case CEPH_MDS_STATE_STOPPED: return "down:stopped"; - /* up and out */ - case CEPH_MDS_STATE_BOOT: return "up:boot"; - case CEPH_MDS_STATE_STANDBY: return "up:standby"; - case CEPH_MDS_STATE_STANDBY_REPLAY: return "up:standby-replay"; - case CEPH_MDS_STATE_CREATING: return "up:creating"; - case CEPH_MDS_STATE_STARTING: return "up:starting"; - /* up and in */ - case CEPH_MDS_STATE_REPLAY: return "up:replay"; - case CEPH_MDS_STATE_RESOLVE: return "up:resolve"; - case CEPH_MDS_STATE_RECONNECT: return "up:reconnect"; - case CEPH_MDS_STATE_REJOIN: return "up:rejoin"; - case CEPH_MDS_STATE_CLIENTREPLAY: return "up:clientreplay"; - case CEPH_MDS_STATE_ACTIVE: return "up:active"; - case CEPH_MDS_STATE_STOPPING: return "up:stopping"; - default: return ""; - } - return NULL; -} +extern const char *ceph_mds_state_name(int s); /* @@ -394,20 +217,7 @@ enum { CEPH_SESSION_RECALL_STATE, }; -static inline const char *ceph_session_op_name(int op) -{ - switch (op) { - case CEPH_SESSION_REQUEST_OPEN: return "request_open"; - case CEPH_SESSION_OPEN: return "open"; - case CEPH_SESSION_REQUEST_CLOSE: return "request_close"; - case CEPH_SESSION_CLOSE: return "close"; - case CEPH_SESSION_REQUEST_RENEWCAPS: return "request_renewcaps"; - case CEPH_SESSION_RENEWCAPS: return "renewcaps"; - case CEPH_SESSION_STALE: return "stale"; - case CEPH_SESSION_RECALL_STATE: return "recall_state"; - default: return "???"; - } -} +extern const char *ceph_session_op_name(int op); struct ceph_mds_session_head { __le32 op; @@ -453,33 +263,8 @@ enum { CEPH_MDS_OP_LSSNAP = 0x00402, }; -static inline const char *ceph_mds_op_name(int op) -{ - switch (op) { - case CEPH_MDS_OP_LOOKUP: return "lookup"; - case CEPH_MDS_OP_LOOKUPHASH: return "lookuphash"; - case CEPH_MDS_OP_LOOKUPPARENT: return "lookupparent"; - case CEPH_MDS_OP_GETATTR: return "getattr"; - case CEPH_MDS_OP_SETXATTR: return "setxattr"; - case CEPH_MDS_OP_SETATTR: return "setattr"; - case CEPH_MDS_OP_RMXATTR: return "rmxattr"; - case CEPH_MDS_OP_READDIR: return "readdir"; - case CEPH_MDS_OP_MKNOD: return "mknod"; - case CEPH_MDS_OP_LINK: return "link"; - case CEPH_MDS_OP_UNLINK: return "unlink"; - case CEPH_MDS_OP_RENAME: return "rename"; - case CEPH_MDS_OP_MKDIR: return "mkdir"; - case CEPH_MDS_OP_RMDIR: return "rmdir"; - case CEPH_MDS_OP_SYMLINK: return "symlink"; - case CEPH_MDS_OP_CREATE: return "create"; - case CEPH_MDS_OP_OPEN: return "open"; - case CEPH_MDS_OP_LOOKUPSNAP: return "lookupsnap"; - case CEPH_MDS_OP_LSSNAP: return "lssnap"; - case CEPH_MDS_OP_MKSNAP: return "mksnap"; - case CEPH_MDS_OP_RMSNAP: return "rmsnap"; - default: return "???"; - } -} +extern const char *ceph_mds_op_name(int op); + #define CEPH_SETATTR_MODE 1 #define CEPH_SETATTR_UID 2 @@ -491,7 +276,7 @@ static inline const char *ceph_mds_op_name(int op) union ceph_mds_request_args { struct { - __le32 mask; /* CEPH_CAP_* */ + __le32 mask; /* CEPH_CAP_* */ } __attribute__ ((packed)) getattr; struct { __le32 mode; @@ -499,12 +284,12 @@ union ceph_mds_request_args { __le32 gid; struct ceph_timespec mtime; struct ceph_timespec atime; - __le64 size, old_size; - __le32 mask; /* CEPH_SETATTR_* */ + __le64 size, old_size; /* old_size needed by truncate */ + __le32 mask; /* CEPH_SETATTR_* */ } __attribute__ ((packed)) setattr; struct { - __le32 frag; - __le32 max_entries; + __le32 frag; /* which dir fragment */ + __le32 max_entries; /* how many dentries to grab */ } __attribute__ ((packed)) readdir; struct { __le32 mode; @@ -516,6 +301,11 @@ union ceph_mds_request_args { struct { __le32 flags; __le32 mode; + __le32 stripe_unit; /* layout for newly created file */ + __le32 stripe_count; /* ... */ + __le32 object_size; + __le32 file_replication; + __le32 preferred; } __attribute__ ((packed)) open; struct { __le32 flags; @@ -530,22 +320,24 @@ union ceph_mds_request_args { struct ceph_mds_request_head { __le64 tid, oldest_client_tid; - __le32 mdsmap_epoch; /* on client */ - __le32 flags; - __u8 num_retry, num_fwd; - __le16 num_releases; - __le32 op; + __le32 mdsmap_epoch; /* on client */ + __le32 flags; /* CEPH_MDS_FLAG_* */ + __u8 num_retry, num_fwd; /* count retry, fwd attempts */ + __le16 num_releases; /* # include cap/lease release records */ + __le32 op; /* mds op code */ __le32 caller_uid, caller_gid; - __le64 ino; /* use this ino for openc, mkdir, mknod, etc. */ + __le64 ino; /* use this ino for openc, mkdir, mknod, + etc. (if replaying) */ union ceph_mds_request_args args; } __attribute__ ((packed)); +/* cap/lease release record */ struct ceph_mds_request_release { - __le64 ino, cap_id; - __le32 caps, wanted; + __le64 ino, cap_id; /* ino and unique cap id */ + __le32 caps, wanted; /* new issued, wanted */ __le32 seq, issue_seq, mseq; - __le32 dname_seq; - __le32 dname_len; /* if releasing a dentry lease; string follows. */ + __le32 dname_seq; /* if releasing a dentry lease, a */ + __le32 dname_len; /* string follows. */ } __attribute__ ((packed)); /* client reply */ @@ -554,38 +346,41 @@ struct ceph_mds_reply_head { __le32 op; __le32 result; __le32 mdsmap_epoch; - __u8 safe; - __u8 is_dentry, is_target; + __u8 safe; /* true if committed to disk */ + __u8 is_dentry, is_target; /* true if dentry, target inode records + are included with reply */ } __attribute__ ((packed)); /* one for each node split */ struct ceph_frag_tree_split { - __le32 frag; /* this frag splits... */ - __le32 by; /* ...by this many bits */ + __le32 frag; /* this frag splits... */ + __le32 by; /* ...by this many bits */ } __attribute__ ((packed)); struct ceph_frag_tree_head { - __le32 nsplits; + __le32 nsplits; /* num ceph_frag_tree_split records */ struct ceph_frag_tree_split splits[]; } __attribute__ ((packed)); +/* capability issue, for bundling with mds reply */ struct ceph_mds_reply_cap { - __le32 caps, wanted; + __le32 caps, wanted; /* caps issued, wanted */ __le64 cap_id; __le32 seq, mseq; - __le64 realm; - __le32 ttl_ms; /* ttl, in ms. if readonly and unwanted. */ - __u8 flags; + __le64 realm; /* snap realm */ + __u8 flags; /* CEPH_CAP_FLAG_* */ } __attribute__ ((packed)); -#define CEPH_CAP_FLAG_AUTH 1 +#define CEPH_CAP_FLAG_AUTH 1 /* cap is issued by auth mds */ +/* inode record, for bundling with mds reply */ struct ceph_mds_reply_inode { __le64 ino; __le64 snapid; __le32 rdev; - __le64 version; - struct ceph_mds_reply_cap cap; + __le64 version; /* inode version */ + __le64 xattr_version; /* version for xattr blob */ + struct ceph_mds_reply_cap cap; /* caps issued for this inode */ struct ceph_file_layout layout; struct ceph_timespec ctime, mtime, atime; __le32 time_warp_seq; @@ -595,22 +390,21 @@ struct ceph_mds_reply_inode { __le32 nlink; __le64 files, subdirs, rbytes, rfiles, rsubdirs; /* dir stats */ struct ceph_timespec rctime; - __le64 xattr_version; - struct ceph_frag_tree_head fragtree; + struct ceph_frag_tree_head fragtree; /* (must be at end of struct) */ } __attribute__ ((packed)); /* followed by frag array, then symlink string, then xattr blob */ /* reply_lease follows dname, and reply_inode */ struct ceph_mds_reply_lease { - __le16 mask; - __le32 duration_ms; + __le16 mask; /* lease type(s) */ + __le32 duration_ms; /* lease duration */ __le32 seq; } __attribute__ ((packed)); struct ceph_mds_reply_dirfrag { - __le32 frag; /* fragment */ - __le32 auth; /* auth mds, if this is a delegation point */ - __le32 ndist; /* number of mds' this is replicated on */ + __le32 frag; /* fragment */ + __le32 auth; /* auth mds, if this is a delegation point */ + __le32 ndist; /* number of mds' this is replicated on */ __le32 dist[]; } __attribute__ ((packed)); @@ -622,26 +416,7 @@ struct ceph_mds_reply_dirfrag { #define CEPH_FILE_MODE_LAZY 4 /* lazy io */ #define CEPH_FILE_MODE_NUM 8 /* bc these are bit fields.. mostly */ -static inline int ceph_flags_to_mode(int flags) -{ -#ifdef O_DIRECTORY /* fixme */ - if ((flags & O_DIRECTORY) == O_DIRECTORY) - return CEPH_FILE_MODE_PIN; -#endif -#ifdef O_LAZY - if (flags & O_LAZY) - return CEPH_FILE_MODE_LAZY; -#endif - if ((flags & O_APPEND) == O_APPEND) - flags |= O_WRONLY; - - flags &= O_ACCMODE; - if ((flags & O_RDWR) == O_RDWR) - return CEPH_FILE_MODE_RDWR; - if ((flags & O_WRONLY) == O_WRONLY) - return CEPH_FILE_MODE_WR; - return CEPH_FILE_MODE_RD; -} +int ceph_flags_to_mode(int flags); /* capability bits */ @@ -705,7 +480,7 @@ static inline int ceph_flags_to_mode(int flags) CEPH_CAP_LINK_SHARED | \ CEPH_CAP_XATTR_SHARED | \ CEPH_CAP_FILE_SHARED) -#define CEPH_CAP_ANY_RD (CEPH_CAP_ANY_SHARED | CEPH_CAP_FILE_RD | \ +#define CEPH_CAP_ANY_RD (CEPH_CAP_ANY_SHARED | CEPH_CAP_FILE_RD | \ CEPH_CAP_FILE_CACHE) #define CEPH_CAP_ANY_EXCL (CEPH_CAP_AUTH_EXCL | \ @@ -721,81 +496,39 @@ static inline int ceph_flags_to_mode(int flags) #define CEPH_CAP_LOCKS (CEPH_LOCK_IFILE | CEPH_LOCK_IAUTH | CEPH_LOCK_ILINK | \ CEPH_LOCK_IXATTR) -static inline int ceph_caps_for_mode(int mode) -{ - switch (mode) { - case CEPH_FILE_MODE_PIN: - return CEPH_CAP_PIN; - case CEPH_FILE_MODE_RD: - return CEPH_CAP_PIN | CEPH_CAP_FILE_SHARED | - CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE; - case CEPH_FILE_MODE_RDWR: - return CEPH_CAP_PIN | CEPH_CAP_FILE_SHARED | - CEPH_CAP_FILE_EXCL | - CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE | - CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER | - CEPH_CAP_AUTH_SHARED | CEPH_CAP_AUTH_EXCL | - CEPH_CAP_XATTR_SHARED | CEPH_CAP_XATTR_EXCL; - case CEPH_FILE_MODE_WR: - return CEPH_CAP_PIN | CEPH_CAP_FILE_SHARED | - CEPH_CAP_FILE_EXCL | - CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER | - CEPH_CAP_AUTH_SHARED | CEPH_CAP_AUTH_EXCL | - CEPH_CAP_XATTR_SHARED | CEPH_CAP_XATTR_EXCL; - } - return 0; -} +int ceph_caps_for_mode(int mode); enum { - CEPH_CAP_OP_GRANT, /* mds->client grant */ - CEPH_CAP_OP_REVOKE, /* mds->client revoke */ - CEPH_CAP_OP_TRUNC, /* mds->client trunc notify */ - CEPH_CAP_OP_EXPORT, /* mds has exported the cap */ - CEPH_CAP_OP_IMPORT, /* mds has imported the cap from specified mds */ - CEPH_CAP_OP_UPDATE, /* client->mds update */ - CEPH_CAP_OP_DROP, /* client->mds drop cap bits */ - CEPH_CAP_OP_FLUSH, /* client->mds cap writeback */ - CEPH_CAP_OP_FLUSH_ACK, /* mds->client flushed */ - CEPH_CAP_OP_FLUSHSNAP, /* client->mds flush snapped metadata */ + CEPH_CAP_OP_GRANT, /* mds->client grant */ + CEPH_CAP_OP_REVOKE, /* mds->client revoke */ + CEPH_CAP_OP_TRUNC, /* mds->client trunc notify */ + CEPH_CAP_OP_EXPORT, /* mds has exported the cap */ + CEPH_CAP_OP_IMPORT, /* mds has imported the cap */ + CEPH_CAP_OP_UPDATE, /* client->mds update */ + CEPH_CAP_OP_DROP, /* client->mds drop cap bits */ + CEPH_CAP_OP_FLUSH, /* client->mds cap writeback */ + CEPH_CAP_OP_FLUSH_ACK, /* mds->client flushed */ + CEPH_CAP_OP_FLUSHSNAP, /* client->mds flush snapped metadata */ CEPH_CAP_OP_FLUSHSNAP_ACK, /* mds->client flushed snapped metadata */ - CEPH_CAP_OP_RELEASE, /* client->mds release (clean) cap */ - CEPH_CAP_OP_RENEW, /* client->mds renewal request */ + CEPH_CAP_OP_RELEASE, /* client->mds release (clean) cap */ + CEPH_CAP_OP_RENEW, /* client->mds renewal request */ }; -static inline const char *ceph_cap_op_name(int op) -{ - switch (op) { - case CEPH_CAP_OP_GRANT: return "grant"; - case CEPH_CAP_OP_REVOKE: return "revoke"; - case CEPH_CAP_OP_TRUNC: return "trunc"; - case CEPH_CAP_OP_EXPORT: return "export"; - case CEPH_CAP_OP_IMPORT: return "import"; - case CEPH_CAP_OP_UPDATE: return "update"; - case CEPH_CAP_OP_DROP: return "drop"; - case CEPH_CAP_OP_FLUSH: return "flush"; - case CEPH_CAP_OP_FLUSH_ACK: return "flush_ack"; - case CEPH_CAP_OP_FLUSHSNAP: return "flushsnap"; - case CEPH_CAP_OP_FLUSHSNAP_ACK: return "flushsnap_ack"; - case CEPH_CAP_OP_RELEASE: return "release"; - case CEPH_CAP_OP_RENEW: return "renew"; - default: return "???"; - } -} +extern const char *ceph_cap_op_name(int op); /* * caps message, used for capability callbacks, acks, requests, etc. */ struct ceph_mds_caps { - __le32 op; + __le32 op; /* CEPH_CAP_OP_* */ __le64 ino, realm; __le64 cap_id; __le32 seq, issue_seq; - __le32 caps, wanted, dirty; + __le32 caps, wanted, dirty; /* latest issued/wanted/dirty */ __le32 migrate_seq; __le64 snap_follows; __le32 snap_trace_len; - __le32 ttl_ms; /* for IMPORT op only */ - __le64 client_tid; /* for FLUSH(SNAP) -> FLUSH(SNAP)_ACK */ + __le64 client_tid; /* for FLUSH(SNAP) -> FLUSH(SNAP)_ACK */ /* authlock */ __le32 uid, gid, mode; @@ -815,8 +548,9 @@ struct ceph_mds_caps { __le32 time_warp_seq; } __attribute__ ((packed)); +/* cap release msg head */ struct ceph_mds_cap_release { - __le32 num; + __le32 num; /* number of cap_items that follow */ } __attribute__ ((packed)); struct ceph_mds_cap_item { @@ -830,28 +564,19 @@ struct ceph_mds_cap_item { #define CEPH_MDS_LEASE_RENEW 3 /* client <-> mds */ #define CEPH_MDS_LEASE_REVOKE_ACK 4 /* client -> mds */ -static inline const char *ceph_lease_op_name(int o) -{ - switch (o) { - case CEPH_MDS_LEASE_REVOKE: return "revoke"; - case CEPH_MDS_LEASE_RELEASE: return "release"; - case CEPH_MDS_LEASE_RENEW: return "renew"; - case CEPH_MDS_LEASE_REVOKE_ACK: return "revoke_ack"; - default: return "???"; - } -} +extern const char *ceph_lease_op_name(int o); +/* lease msg header */ struct ceph_mds_lease { - __u8 action; - __le16 mask; + __u8 action; /* CEPH_MDS_LEASE_* */ + __le16 mask; /* which lease */ __le64 ino; - __le64 first, last; + __le64 first, last; /* snap range */ __le32 seq; - __le32 duration_ms; /* duration of renewal */ + __le32 duration_ms; /* duration of renewal */ } __attribute__ ((packed)); /* followed by a __le32+string for dname */ - /* client reconnect */ struct ceph_mds_cap_reconnect { __le64 cap_id; @@ -860,13 +585,13 @@ struct ceph_mds_cap_reconnect { __le64 size; struct ceph_timespec mtime, atime; __le64 snaprealm; - __le64 pathbase; + __le64 pathbase; /* base ino for our path to this ino */ } __attribute__ ((packed)); /* followed by encoded string */ struct ceph_mds_snaprealm_reconnect { - __le64 ino; - __le64 seq; + __le64 ino; /* snap realm base */ + __le64 seq; /* snap seq for this snap realm */ __le64 parent; /* parent realm */ } __attribute__ ((packed)); @@ -880,23 +605,15 @@ enum { CEPH_SNAP_OP_SPLIT, }; -static inline const char *ceph_snap_op_name(int o) -{ - switch (o) { - case CEPH_SNAP_OP_UPDATE: return "update"; - case CEPH_SNAP_OP_CREATE: return "create"; - case CEPH_SNAP_OP_DESTROY: return "destroy"; - case CEPH_SNAP_OP_SPLIT: return "split"; - default: return "???"; - } -} +extern const char *ceph_snap_op_name(int o); +/* snap msg header */ struct ceph_mds_snap_head { - __le32 op; - __le64 split; - __le32 num_split_inos; - __le32 num_split_realms; - __le32 trace_len; + __le32 op; /* CEPH_SNAP_OP_* */ + __le64 split; /* ino to split off, if any */ + __le32 num_split_inos; /* # inos belonging to new child realm */ + __le32 num_split_realms; /* # child realms udner new child realm */ + __le32 trace_len; /* size of snap trace blob */ } __attribute__ ((packed)); /* followed by split ino list, then split realms, then the trace blob */ diff --git a/wireshark/ceph/msgr.h b/wireshark/ceph/msgr.h index 52d2555743f..9abc879e25b 100644 --- a/wireshark/ceph/msgr.h +++ b/wireshark/ceph/msgr.h @@ -21,7 +21,7 @@ * whenever the wire protocol changes. try to keep this string length * constant. */ -#define CEPH_BANNER "ceph 014\n" +#define CEPH_BANNER "ceph v022" #define CEPH_BANNER_MAX_LEN 30 @@ -42,8 +42,8 @@ static inline __s32 ceph_seq_cmp(__u32 a, __u32 b) * network, e.g. 'mds0' or 'osd3'. */ struct ceph_entity_name { - __le32 type; - __le32 num; + __u8 type; /* CEPH_ENTITY_TYPE_* */ + __le64 num; } __attribute__ ((packed)); #define CEPH_ENTITY_TYPE_MON 1 @@ -58,14 +58,14 @@ struct ceph_entity_name { struct ceph_entity_addr { __le32 erank; /* entity's rank in process */ __le32 nonce; /* unique id for process (e.g. pid) */ - struct sockaddr_in ipaddr; + struct sockaddr_storage in_addr; } __attribute__ ((packed)); static inline bool ceph_entity_addr_is_local(const struct ceph_entity_addr *a, const struct ceph_entity_addr *b) { return a->nonce == b->nonce && - a->ipaddr.sin_addr.s_addr == b->ipaddr.sin_addr.s_addr; + memcmp(&a->in_addr, &b->in_addr, sizeof(a->in_addr)) == 0; } static inline bool ceph_entity_addr_equal(const struct ceph_entity_addr *a, @@ -90,24 +90,28 @@ struct ceph_entity_inst { #define CEPH_MSGR_TAG_RETRY_GLOBAL 5 /* server->client + gseq: try again with higher gseq */ #define CEPH_MSGR_TAG_CLOSE 6 /* closing pipe */ -#define CEPH_MSGR_TAG_MSG 10 /* message */ -#define CEPH_MSGR_TAG_ACK 11 /* message ack */ +#define CEPH_MSGR_TAG_MSG 7 /* message */ +#define CEPH_MSGR_TAG_ACK 8 /* message ack */ +#define CEPH_MSGR_TAG_KEEPALIVE 9 /* just a keepalive byte! */ +#define CEPH_MSGR_TAG_BADPROTOVER 10 /* bad protocol version */ /* * connection negotiation */ struct ceph_msg_connect { - __le32 host_type; /* CEPH_ENTITY_TYPE_* */ - __le32 global_seq; - __le32 connect_seq; - __u8 flags; + __le32 host_type; /* CEPH_ENTITY_TYPE_* */ + __le32 global_seq; /* count connections initiated by this host */ + __le32 connect_seq; /* count connections initiated in this session */ + __le32 protocol_version; + __u8 flags; /* CEPH_MSG_CONNECT_* */ } __attribute__ ((packed)); struct ceph_msg_connect_reply { __u8 tag; __le32 global_seq; __le32 connect_seq; + __le32 protocol_version; __u8 flags; } __attribute__ ((packed)); @@ -121,6 +125,7 @@ struct ceph_msg_header { __le64 seq; /* message seq# for this session */ __le16 type; /* message type */ __le16 priority; /* priority. higher value == higher priority */ + __le16 version; /* version of message encoding */ __le32 front_len; /* bytes in main payload */ __le32 middle_len;/* bytes in middle payload */ @@ -128,11 +133,8 @@ struct ceph_msg_header { __le16 data_off; /* sender: include full offset; receiver: mask against ~PAGE_MASK */ - __u8 mon_protocol, monc_protocol; /* protocol versions, */ - __u8 osd_protocol, osdc_protocol; /* internal and public */ - __u8 mds_protocol, mdsc_protocol; - - struct ceph_entity_inst src, orig_src, dst; + struct ceph_entity_inst src, orig_src; + __le32 dst_erank; __le32 crc; /* header crc32c */ } __attribute__ ((packed)); @@ -145,11 +147,11 @@ struct ceph_msg_header { * follows data payload */ struct ceph_msg_footer { - __le32 flags; __le32 front_crc, middle_crc, data_crc; + __u8 flags; } __attribute__ ((packed)); -#define CEPH_MSG_FOOTER_ABORTED (1<<0) /* drop this message */ +#define CEPH_MSG_FOOTER_COMPLETE (1<<0) /* msg wasn't aborted */ #define CEPH_MSG_FOOTER_NOCRC (1<<1) /* no data crc */ diff --git a/wireshark/ceph/packet-ceph.c b/wireshark/ceph/packet-ceph.c index 0b2f688185f..e6e12206fa2 100644 --- a/wireshark/ceph/packet-ceph.c +++ b/wireshark/ceph/packet-ceph.c @@ -23,49 +23,10 @@ #include #include -// this is needed for ceph_fs to compile in userland -#ifdef _MSC_VER -typedef char __s8; -typedef short __s16; -typedef int __s32; -typedef __int64 __s64; -typedef unsigned char __u8; -typedef unsigned short __u16; -typedef unsigned int __u32; -typedef unsigned __int64 __u64; -typedef __u16 __le16; -typedef __u32 __le32; -typedef __u64 __le64; -#define __attribute__(x) -#define O_ACCMODE (O_RDONLY | O_RDWR | O_WRONLY) -#include -#else -#include -#include -#endif -typedef int bool; - -#define le16_to_cpu(x) (x) -#define le32_to_cpu(x) (x) -#define le64_to_cpu(x) (x) - -typedef guint32 uint32_t; - -#include -#include - -#ifdef _MSC_VER -#pragma pack(1) -#endif -#include "ceph_fs.h" -#ifdef _MSC_VER -#pragma pack() -#endif +#include "types.h" #include "crc32c.h" - - #include #define PROTO_TAG_CEPH "CEPH" @@ -147,7 +108,7 @@ static const value_string packettypenames[] = { { 0, NULL } }; -#define ACK_MSG_SIZE 5 +#define ACK_MSG_SIZE 9 #define TVB_MSG_HEADER_POS(x) (1 + offsetof(struct ceph_msg_header, x)) #define TVB_IS_ACK(ofs) (tvb_get_guint8(tvb, ofs) == CEPH_MSGR_TAG_ACK) #define TVB_MSG_FIELD(func, tvb, ofs, field) func(tvb, ofs + (TVB_IS_ACK(ofs) ? ACK_MSG_SIZE : 0) + TVB_MSG_HEADER_POS(field)) @@ -187,6 +148,7 @@ static gint hf_ceph_hdr_seq_ack = -1; static gint hf_ceph_hdr_seq = -1; static gint hf_ceph_hdr_type = -1; static gint hf_ceph_hdr_priority = -1; +static gint hf_ceph_hdr_version = -1; static gint hf_ceph_hdr_mon_protocol = -1; static gint hf_ceph_hdr_osd_protocol = -1; static gint hf_ceph_hdr_mds_protocol = -1; @@ -323,7 +285,7 @@ void proto_register_ceph (void) { "tag", "ceph.tag", FT_UINT8, BASE_DEC, NULL, 0x0, "hdr: tag", HFILL }}, { &hf_ceph_hdr_seq_ack, - { "ack seq", "ceph.ack.seq", FT_UINT32, BASE_DEC, NULL, 0x0, + { "ack seq", "ceph.ack.seq", FT_UINT64, BASE_DEC, NULL, 0x0, "ack: seq", HFILL }}, { &hf_ceph_hdr_seq, { "seq", "ceph.seq", FT_UINT64, BASE_DEC, NULL, 0x0, @@ -334,6 +296,9 @@ void proto_register_ceph (void) { &hf_ceph_hdr_priority, { "priority", "ceph.priority", FT_UINT16, BASE_DEC, NULL, 0x0, "hdr: priority", HFILL }}, + { &hf_ceph_hdr_version, + { "version", "ceph.version", FT_UINT16, BASE_DEC, NULL, 0x0, + "hdr: version", HFILL }}, { &hf_ceph_hdr_mon_protocol, { "mon_protocol", "ceph.mon_protocol", FT_UINT16, BASE_DEC, NULL, 0x0, "hdr: mon_protocol", HFILL }}, @@ -436,11 +401,11 @@ static guint32 dissect_ceph_banner(tvbuff_t *tvb, proto_tree *tree, guint32 offs proto_tree *ceph_banner_tree = NULL; proto_item *ceph_sub_item = NULL; - ceph_sub_item = proto_tree_add_item( tree, hf_ceph_banner, tvb, offset, 8, TRUE ); + ceph_sub_item = proto_tree_add_item( tree, hf_ceph_banner, tvb, offset, 9, TRUE ); ceph_banner_tree = proto_item_add_subtree(ceph_sub_item, ett_ceph); proto_tree_add_item(ceph_banner_tree, hf_ceph_banner_magic, tvb, offset, 4, TRUE); - proto_tree_add_item(ceph_banner_tree, hf_ceph_banner_version, tvb, offset+4, 4, TRUE); + proto_tree_add_item(ceph_banner_tree, hf_ceph_banner_version, tvb, offset+5, 4, TRUE); return offset+9; } @@ -454,22 +419,22 @@ static guint32 dissect_ceph_entity_addr(tvbuff_t *tvb, proto_tree *tree, guint32 ceph_entity_tree = proto_item_add_subtree(ceph_sub_item, ett_ceph); proto_tree_add_item(ceph_entity_tree, hf_ceph_connect_erank, tvb, offset, 4, TRUE); proto_tree_add_item(ceph_entity_tree, hf_ceph_connect_nonce, tvb, offset+4, 4, TRUE); - offset = dissect_sockaddr_in(tvb, ceph_entity_tree, offset+8); + dissect_sockaddr_in(tvb, ceph_entity_tree, offset+8); #if 0 proto_tree_add_item(ceph_entity_tree, hf_ceph_connect_host_type, tvb, offset, 4, TRUE); offset += 4; #endif - return offset; + return offset + sizeof(struct ceph_entity_addr); } static guint32 dissect_ceph_fsid(tvbuff_t *tvb, proto_tree *tree, guint32 offset) { proto_tree *ceph_entity_tree = NULL; proto_item *ceph_sub_item = NULL; - ceph_fsid_t *fsid; + struct ceph_fsid *fsid; - fsid = (ceph_fsid_t *)tvb_get_ptr(tvb, offset, sizeof(ceph_fsid_t)); + fsid = (struct ceph_fsid *)tvb_get_ptr(tvb, offset, sizeof(struct ceph_fsid)); ceph_sub_item = proto_tree_add_item( tree, hf_ceph_fsid, tvb, offset, sizeof(struct ceph_entity_addr), TRUE ); ceph_entity_tree = proto_item_add_subtree(ceph_sub_item, ett_ceph); @@ -478,9 +443,9 @@ static guint32 dissect_ceph_fsid(tvbuff_t *tvb, proto_tree *tree, guint32 offset proto_tree_add_item(ceph_entity_tree, hf_ceph_connect_nonce, tvb, offset+4, 4, TRUE); proto_tree_add_text(tree, tvb, 0, - sizeof(ceph_fsid_t), "fsid: " FMT_INO "." FMT_INO, ((unsigned long long *)fsid->fsid)[0], ((unsigned long long *)fsid->fsid)[1]); + sizeof(struct ceph_fsid), "fsid: " FMT_INO "." FMT_INO, ((unsigned long long *)fsid->fsid)[0], ((unsigned long long *)fsid->fsid)[1]); - offset += sizeof(ceph_fsid_t); + offset += sizeof(struct ceph_fsid); return offset; } @@ -522,6 +487,7 @@ static guint32 dissect_ceph_client_connect(tvbuff_t *tvb, proto_tree *tree, guin proto_tree *ceph_header_tree = NULL; proto_item *ceph_sub_item = NULL; proto_item *ceph_item = proto_tree_get_parent(tree); + struct ceph_msg_connect *msg; offset = dissect_ceph_banner(tvb, tree, offset); @@ -531,12 +497,22 @@ static guint32 dissect_ceph_client_connect(tvbuff_t *tvb, proto_tree *tree, guin ceph_header_tree = proto_item_add_subtree(ceph_sub_item, ett_ceph); offset = dissect_ceph_entity_addr(tvb, ceph_header_tree, offset); +#if 0 proto_tree_add_item(ceph_header_tree, hf_ceph_connect_host_type, tvb, offset, 4, TRUE); offset += 4; proto_tree_add_item(ceph_header_tree, hf_ceph_connect_global_seq, tvb, offset, 4, TRUE); proto_tree_add_item(ceph_header_tree, hf_ceph_connect_connect_seq, tvb, offset+4, 4, TRUE); proto_tree_add_item(ceph_header_tree, hf_ceph_connect_flags, tvb, offset+8, 1, TRUE); offset += 8; +#endif + + msg = (struct ceph_msg_connect *)tvb_get_ptr(tvb, offset, sizeof(struct ceph_msg_connect)); + PROTO_ADD_TEXT(struct ceph_msg_connect, msg, host_type, "%d"); + PROTO_ADD_TEXT(struct ceph_msg_connect, msg, global_seq, "%d"); + PROTO_ADD_TEXT(struct ceph_msg_connect, msg, connect_seq, "%d"); + PROTO_ADD_TEXT(struct ceph_msg_connect, msg, protocol_version, "%d"); + PROTO_ADD_TEXT(struct ceph_msg_connect, msg, flags, "%x"); + return offset; } @@ -545,6 +521,7 @@ static guint32 dissect_ceph_server_connect(tvbuff_t *tvb, proto_tree *tree, guin proto_tree *ceph_header_tree = NULL; proto_item *ceph_sub_item = NULL; proto_item *ceph_item = proto_tree_get_parent(tree); + struct ceph_msg_connect_reply *msg; offset = dissect_ceph_banner(tvb, tree, offset); @@ -555,11 +532,13 @@ static guint32 dissect_ceph_server_connect(tvbuff_t *tvb, proto_tree *tree, guin offset = dissect_ceph_entity_addr(tvb, ceph_header_tree, offset); - proto_tree_add_item(ceph_header_tree, hf_ceph_hdr_tag, tvb, offset, 1, TRUE); - offset += 1; - proto_tree_add_item(ceph_header_tree, hf_ceph_connect_global_seq, tvb, offset, 4, TRUE); - proto_tree_add_item(ceph_header_tree, hf_ceph_connect_connect_seq, tvb, offset+4, 4, TRUE); - proto_tree_add_item(ceph_header_tree, hf_ceph_connect_flags, tvb, offset+8, 1, TRUE); + msg = (struct ceph_msg_connect_reply *)tvb_get_ptr(tvb, offset, sizeof(struct ceph_msg_connect_reply)); + PROTO_ADD_TEXT(struct ceph_msg_connect_reply, msg, tag, "%d"); + PROTO_ADD_TEXT(struct ceph_msg_connect_reply, msg, global_seq, "%d"); + PROTO_ADD_TEXT(struct ceph_msg_connect_reply, msg, connect_seq, "%d"); + PROTO_ADD_TEXT(struct ceph_msg_connect_reply, msg, protocol_version, "%d"); + PROTO_ADD_TEXT(struct ceph_msg_connect_reply, msg, flags, "%x"); + return offset; } @@ -635,7 +614,7 @@ static guint32 dissect_ceph_mon_statfs_reply(tvbuff_t *tvb, proto_tree *tree, gu return offset + sizeof(struct ceph_mon_statfs_reply); } - +#if 0 static guint32 dissect_ceph_client_osd_getmap(tvbuff_t *tvb, proto_tree *tree, guint32 offset) { struct ceph_osd_getmap *req; @@ -654,12 +633,12 @@ static guint32 dissect_ceph_client_mds_getmap(tvbuff_t *tvb, proto_tree *tree, g req = (struct ceph_mds_getmap *)tvb_get_ptr(tvb, offset, sizeof(struct ceph_mds_getmap)); - PROTO_ADD_TEXT(struct ceph_mds_getmap, req, have_version, "%lld"); + PROTO_ADD_TEXT(struct ceph_mds_getmap, req, monhdr.have_version, "%lld"); dissect_ceph_fsid(tvb, tree, offset + offsetof(struct ceph_mds_getmap, fsid)); return offset + sizeof(struct ceph_mds_getmap); } - +#endif static guint32 dissect_ceph_client_mds_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 offset) { struct ceph_mds_request_head *head; @@ -843,12 +822,6 @@ static guint32 dissect_ceph_client_front(tvbuff_t *tvb, packet_info *pinfo, prot case CEPH_MSG_CLIENT_CAPS: offset = dissect_ceph_client_mds_caps_request(tvb, pinfo, tree, offset); break; - case CEPH_MSG_OSD_GETMAP: - offset = dissect_ceph_client_osd_getmap(tvb, tree, offset); - break; - case CEPH_MSG_MDS_GETMAP: - offset = dissect_ceph_client_mds_getmap(tvb, tree, offset); - break; default: break; } @@ -877,7 +850,7 @@ static guint32 dissect_ceph_generic(tvbuff_t *tvb, packet_info *pinfo, proto_tre if (tag == CEPH_MSGR_TAG_ACK) { proto_tree_add_item(ceph_header_tree, hf_ceph_hdr_tag, tvb, offset, 1, TRUE); - proto_tree_add_item(ceph_header_tree, hf_ceph_hdr_seq_ack, tvb, offset+1, 4, TRUE); + proto_tree_add_item(ceph_header_tree, hf_ceph_hdr_seq_ack, tvb, offset+1, 8, TRUE); offset += ACK_MSG_SIZE; } @@ -889,16 +862,13 @@ static guint32 dissect_ceph_generic(tvbuff_t *tvb, packet_info *pinfo, proto_tre PROTO_ADD_ITEM(ceph_header_tree, struct ceph_msg_header, hf_ceph_hdr_seq, header, seq); PROTO_ADD_ITEM(ceph_header_tree, struct ceph_msg_header, hf_ceph_hdr_type, header, type); PROTO_ADD_ITEM(ceph_header_tree, struct ceph_msg_header, hf_ceph_hdr_priority, header, priority); - PROTO_ADD_ITEM(ceph_header_tree, struct ceph_msg_header, hf_ceph_hdr_mon_protocol, header, mon_protocol); - PROTO_ADD_ITEM(ceph_header_tree, struct ceph_msg_header, hf_ceph_hdr_osd_protocol, header, osd_protocol); - PROTO_ADD_ITEM(ceph_header_tree, struct ceph_msg_header, hf_ceph_hdr_mds_protocol, header, mds_protocol); + PROTO_ADD_ITEM(ceph_header_tree, struct ceph_msg_header, hf_ceph_hdr_version, header, version); PROTO_ADD_ITEM(ceph_header_tree, struct ceph_msg_header, hf_ceph_hdr_front_len, header, front_len); PROTO_ADD_ITEM(ceph_header_tree, struct ceph_msg_header, hf_ceph_hdr_middle_len, header, middle_len); PROTO_ADD_ITEM(ceph_header_tree, struct ceph_msg_header, hf_ceph_hdr_data_off, header, data_off); PROTO_ADD_ITEM(ceph_header_tree, struct ceph_msg_header, hf_ceph_hdr_data_len, header, data_len); dissect_ceph_entity_inst(tvb, ceph_header_tree, offset + offsetof(struct ceph_msg_header, src)); dissect_ceph_entity_inst(tvb, ceph_header_tree, offset + offsetof(struct ceph_msg_header, orig_src)); - dissect_ceph_entity_inst(tvb, ceph_header_tree, offset + offsetof(struct ceph_msg_header, dst)); PROTO_ADD_ITEM(ceph_header_tree, struct ceph_msg_header, hf_ceph_hdr_crc, header, crc); offset += sizeof(struct ceph_msg_header); @@ -1101,8 +1071,8 @@ static guint dissect_ceph_acks(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr if (tree) { proto_tree_add_item(tree, proto_ceph, tvb, 0, 5, TRUE); proto_tree_add_item(tree, hf_ceph_hdr_tag, tvb, offset, 1, TRUE); - proto_tree_add_item(tree, hf_ceph_hdr_seq_ack, tvb, offset+1, 4, TRUE); - offset += 5; + proto_tree_add_item(tree, hf_ceph_hdr_seq_ack, tvb, offset+1, 8, TRUE); + offset += 9; } return offset; diff --git a/wireshark/ceph/plugin.c b/wireshark/ceph/plugin.c index 0306fcc6a8d..254febabc24 100644 --- a/wireshark/ceph/plugin.c +++ b/wireshark/ceph/plugin.c @@ -1,5 +1,8 @@ -/* Do not modify this file. */ -/* It is created automatically by the Makefile. */ +/* + * Do not modify this file. + * + * It is created automatically by Makefile or Makefile.nmake. + */ #ifdef HAVE_CONFIG_H # include "config.h" diff --git a/wireshark/ceph/rados.h b/wireshark/ceph/rados.h index d6067072797..a48cf4ae391 100644 --- a/wireshark/ceph/rados.h +++ b/wireshark/ceph/rados.h @@ -1,12 +1,9 @@ -// -*- mode:C; tab-width:8; c-basic-offset:8; indent-tabs-mode:t -*- -// vim: ts=8 sw=8 smarttab - #ifndef __RADOS_H #define __RADOS_H /* - * Data types for RADOS, the distributed object storage layer used by - * the Ceph file system. + * Data types for the Ceph distributed object storage layer RADOS + * (Reliable Autonomic Distributed Object Store). */ #include "msgr.h" @@ -14,10 +11,12 @@ /* * fs id */ -typedef struct { unsigned char fsid[16]; } ceph_fsid_t; +struct ceph_fsid { + unsigned char fsid[16]; +}; -static inline int ceph_fsid_compare(const ceph_fsid_t *a, - const ceph_fsid_t *b) +static inline int ceph_fsid_compare(const struct ceph_fsid *a, + const struct ceph_fsid *b) { return memcmp(a, b, sizeof(*a)); } @@ -26,9 +25,9 @@ static inline int ceph_fsid_compare(const ceph_fsid_t *a, * ino, object, etc. */ typedef __le64 ceph_snapid_t; -#define CEPH_MAXSNAP ((__u64)(-3)) -#define CEPH_SNAPDIR ((__u64)(-1)) -#define CEPH_NOSNAP ((__u64)(-2)) +#define CEPH_SNAPDIR ((__u64)(-1)) /* reserved for hidden .snap dir */ +#define CEPH_NOSNAP ((__u64)(-2)) /* "head", "live" revision */ +#define CEPH_MAXSNAP ((__u64)(-3)) /* largest valid snapid */ struct ceph_timespec { __le32 tv_sec; @@ -56,20 +55,15 @@ struct ceph_timespec { * placement group. * we encode this into one __le64. */ -#define CEPH_PG_TYPE_REP 1 -#define CEPH_PG_TYPE_RAID4 2 union ceph_pg { __u64 pg64; struct { __s16 preferred; /* preferred primary osd */ __u16 ps; /* placement seed */ - __u32 pool; /* implies crush ruleset */ - } pg; + __u32 pool; /* object pool */ + } __attribute__ ((packed)) pg; } __attribute__ ((packed)); -#define ceph_pg_is_rep(pg) ((pg).pg.type == CEPH_PG_TYPE_REP) -#define ceph_pg_is_raid4(pg) ((pg).pg.type == CEPH_PG_TYPE_RAID4) - /* * pg_pool is a set of pgs storing a pool of objects * @@ -87,15 +81,17 @@ union ceph_pg { * * lpgp_num -- as above. */ +#define CEPH_PG_TYPE_REP 1 +#define CEPH_PG_TYPE_RAID4 2 struct ceph_pg_pool { - __u8 type; - __u8 size; - __u8 crush_ruleset; - __le32 pg_num, pgp_num; - __le32 lpg_num, lpgp_num; - __le32 last_change; /* most recent epoch changed */ - __le64 snap_seq; - __le32 snap_epoch; + __u8 type; /* CEPH_PG_TYPE_* */ + __u8 size; /* number of osds in each pg */ + __u8 crush_ruleset; /* crush placement rule */ + __le32 pg_num, pgp_num; /* number of pg's */ + __le32 lpg_num, lpgp_num; /* number of localized pg's */ + __le32 last_change; /* most recent epoch changed */ + __le64 snap_seq; /* seq for per-pool snapshot */ + __le32 snap_epoch; /* epoch of last snap */ __le32 num_snaps; __le32 num_removed_snap_intervals; } __attribute__ ((packed)); @@ -122,7 +118,7 @@ static inline int ceph_stable_mod(int x, int b, int bmask) */ struct ceph_object_layout { __le64 ol_pgid; /* raw pg, with _full_ ps precision. */ - __le32 ol_stripe_unit; + __le32 ol_stripe_unit; /* for per-object parity, if any */ } __attribute__ ((packed)); /* @@ -194,11 +190,11 @@ enum { CEPH_OSD_OP_SETTRUNC = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 8, CEPH_OSD_OP_TRIMTRUNC = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 9, - CEPH_OSD_OP_TMAPUP = CEPH_OSD_OP_MODE_RMW | CEPH_OSD_OP_TYPE_DATA | 10, - CEPH_OSD_OP_TMAPPUT = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 11, - CEPH_OSD_OP_TMAPGET = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 12, + CEPH_OSD_OP_TMAPUP = CEPH_OSD_OP_MODE_RMW | CEPH_OSD_OP_TYPE_DATA | 10, + CEPH_OSD_OP_TMAPPUT = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 11, + CEPH_OSD_OP_TMAPGET = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 12, - CEPH_OSD_OP_CREATE = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 13, + CEPH_OSD_OP_CREATE = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 13, /** attrs **/ /* read */ @@ -271,56 +267,7 @@ static inline int ceph_osd_op_mode_modify(int op) #define CEPH_OSD_TMAP_SET 's' #define CEPH_OSD_TMAP_RM 'r' -static inline const char *ceph_osd_op_name(int op) -{ - switch (op) { - case CEPH_OSD_OP_READ: return "read"; - case CEPH_OSD_OP_STAT: return "stat"; - - case CEPH_OSD_OP_MASKTRUNC: return "masktrunc"; - - case CEPH_OSD_OP_WRITE: return "write"; - case CEPH_OSD_OP_DELETE: return "delete"; - case CEPH_OSD_OP_TRUNCATE: return "truncate"; - case CEPH_OSD_OP_ZERO: return "zero"; - case CEPH_OSD_OP_WRITEFULL: return "writefull"; - - case CEPH_OSD_OP_APPEND: return "append"; - case CEPH_OSD_OP_STARTSYNC: return "startsync"; - case CEPH_OSD_OP_SETTRUNC: return "settrunc"; - case CEPH_OSD_OP_TRIMTRUNC: return "trimtrunc"; - - case CEPH_OSD_OP_TMAPUP: return "tmapup"; - case CEPH_OSD_OP_TMAPGET: return "tmapget"; - case CEPH_OSD_OP_TMAPPUT: return "tmapput"; - - case CEPH_OSD_OP_GETXATTR: return "getxattr"; - case CEPH_OSD_OP_GETXATTRS: return "getxattrs"; - case CEPH_OSD_OP_SETXATTR: return "setxattr"; - case CEPH_OSD_OP_SETXATTRS: return "setxattrs"; - case CEPH_OSD_OP_RESETXATTRS: return "resetxattrs"; - case CEPH_OSD_OP_RMXATTR: return "rmxattr"; - - case CEPH_OSD_OP_PULL: return "pull"; - case CEPH_OSD_OP_PUSH: return "push"; - case CEPH_OSD_OP_BALANCEREADS: return "balance-reads"; - case CEPH_OSD_OP_UNBALANCEREADS: return "unbalance-reads"; - case CEPH_OSD_OP_SCRUB: return "scrub"; - - case CEPH_OSD_OP_WRLOCK: return "wrlock"; - case CEPH_OSD_OP_WRUNLOCK: return "wrunlock"; - case CEPH_OSD_OP_RDLOCK: return "rdlock"; - case CEPH_OSD_OP_RDUNLOCK: return "rdunlock"; - case CEPH_OSD_OP_UPLOCK: return "uplock"; - case CEPH_OSD_OP_DNLOCK: return "dnlock"; - - case CEPH_OSD_OP_CALL: return "call"; - - case CEPH_OSD_OP_PGLS: return "pgls"; - - default: return "???"; - } -} +extern const char *ceph_osd_op_name(int op); /* @@ -343,7 +290,7 @@ enum { }; enum { - CEPH_OSD_OP_FLAG_EXCL = 1, + CEPH_OSD_OP_FLAG_EXCL = 1, /* EXCL object create */ }; #define EOLDSNAPC ERESTART /* ORDERSNAP flag set; writer has old snapc*/ @@ -354,31 +301,29 @@ enum { * payload */ struct ceph_osd_op { - __le16 op; + __le16 op; /* CEPH_OSD_OP_* */ + __le32 flags; /* CEPH_OSD_FLAG_* */ union { struct { __le64 offset, length; - } __attribute__ ((packed)); + } __attribute__ ((packed)) extent; struct { __le32 name_len; __le32 value_len; - } __attribute__ ((packed)); + } __attribute__ ((packed)) xattr; struct { __le64 truncate_size; __le32 truncate_seq; - } __attribute__ ((packed)); + } __attribute__ ((packed)) trunc; struct { __u8 class_len; __u8 method_len; __u8 argc; __le32 indata_len; - } __attribute__ ((packed)); + } __attribute__ ((packed)) cls; struct { - __le64 pgls_cookie, count; - } __attribute__ ((packed)); - struct { - __le32 flags; - } __attribute__ ((packed)); + __le64 cookie, count; + } __attribute__ ((packed)) pgls; }; __le32 payload_len; } __attribute__ ((packed)); @@ -388,20 +333,19 @@ struct ceph_osd_op { * ceph_osd_op object operations. */ struct ceph_osd_request_head { - __le64 tid; - __le32 client_inc; - struct ceph_object_layout layout; - __le32 osdmap_epoch; + __le64 tid; /* transaction id */ + __le32 client_inc; /* client incarnation */ + struct ceph_object_layout layout; /* pgid */ + __le32 osdmap_epoch; /* client's osdmap epoch */ __le32 flags; - struct ceph_timespec mtime; + struct ceph_timespec mtime; /* for mutations only */ struct ceph_eversion reassert_version; /* if we are replaying op */ - __le32 object_len; - __le32 ticket_len; + __le32 object_len; /* length of object name */ - __le64 snapid; + __le64 snapid; /* snapid to read */ __le64 snap_seq; /* writer's snap context */ __le32 num_snaps; @@ -410,16 +354,16 @@ struct ceph_osd_request_head { } __attribute__ ((packed)); struct ceph_osd_reply_head { - __le64 tid; - __le32 client_inc; + __le64 tid; /* transaction id */ + __le32 client_inc; /* client incarnation */ __le32 flags; struct ceph_object_layout layout; __le32 osdmap_epoch; - struct ceph_eversion reassert_version; + struct ceph_eversion reassert_version; /* for replaying uncommitted */ - __le32 result; + __le32 result; /* result code */ - __le32 object_len; + __le32 object_len; /* length of object name */ __le32 num_ops; struct ceph_osd_op ops[0]; /* ops[], object */ } __attribute__ ((packed)); diff --git a/wireshark/ceph/types.h b/wireshark/ceph/types.h new file mode 100644 index 00000000000..540286977ef --- /dev/null +++ b/wireshark/ceph/types.h @@ -0,0 +1,52 @@ +#ifndef _WS_CEPH_TYPES_H +#define _WS_CEPH_TYPES_H + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include + +// this is needed for ceph_fs to compile in userland +#ifdef _MSC_VER +typedef char __s8; +typedef short __s16; +typedef int __s32; +typedef __int64 __s64; +typedef unsigned char __u8; +typedef unsigned short __u16; +typedef unsigned int __u32; +typedef unsigned __int64 __u64; +typedef __u16 __le16; +typedef __u32 __le32; +typedef __u64 __le64; +#define __attribute__(x) +#define O_ACCMODE (O_RDONLY | O_RDWR | O_WRONLY) +#include +#else +#include +#include +#endif +typedef int bool; + +#define le16_to_cpu(x) (x) +#define le32_to_cpu(x) (x) +#define le64_to_cpu(x) (x) + + +typedef guint32 uint32_t; + +#include +#include + +#ifdef _MSC_VER +#pragma pack(1) +#endif +#include "ceph_fs.h" +#ifdef _MSC_VER +#pragma pack() +#endif + + + +#endif -- cgit v1.2.1